Ionic android gradle build takes long time!


#1

Ionic info:
global packages:

@ionic/cli-utils : 1.0.0
Cordova CLI      : 7.0.1
Ionic CLI        : 3.0.0

local packages:

@ionic/app-scripts              : 1.3.12
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.2.3 windows 5.0.0
Ionic Framework                 : ionic-angular 3.5.0

System:

Node       : v6.11.0
OS         : Windows 10
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed

ionic cordova build android --prod
Running app-scripts build: --prod --iscordovaserve --externalIpRequired --nobrowser

[13:01:03] build prod started …
[13:01:03] clean started …
[13:01:03] clean finished in 56 ms
[13:01:03] copy started …
[13:01:03] ngc started …
[13:01:13] ngc finished in 9.31 s
[13:01:13] preprocess started …
[13:01:13] deeplinks started …
[13:01:13] deeplinks finished in 141 ms
[13:01:13] optimization started …
[13:01:13] copy finished in 9.81 s
[13:01:23] optimization finished in 10.36 s
[13:01:23] preprocess finished in 10.50 s
[13:01:23] webpack started …
[13:01:29] webpack finished in 6.00 s
[13:01:29] sass started …
[13:01:29] uglifyjs started …
[13:01:30] sass finished in 949 ms
[13:01:30] cleancss started …
[13:01:31] cleancss finished in 1.20 s
[13:01:39] uglifyjs finished in 9.60 s
[13:01:39] postprocess started …
[13:01:39] postprocess finished in less than 1 ms
[13:01:39] lint started …
[13:01:39] build prod finished in 35.53 s

cordova build android

ANDROID_HOME=C:\Users\username\AppData\Local\Android
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_112howAlert(Err
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated a
[13:02:1at build_b1us5zh0o4kbvz0k2z0f5tp0z.run(C:\Users
The JavaCompile.setDependencyCacheDir() method has been
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated
:preBuild UP-TO-DATEalert = that.utilities.showAlert(Err
:preDebugBuild UP-TO-DATEsent();
:checkDebugManifest
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATErt’
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATEies.showAlert(Err
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint UP-TO-DATE
:CordovaLib:copyDebugLint UP-TO-DATE code/Synergita src
:CordovaLib:mergeDebugShaders UP-TO-DATEt never used.
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATEstring, passwo
:CordovaLib:mergeDebugAssets UP-TO-DATE: NavController,
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:incrementalDebugJavaCompilationSafeguard UP-
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug U
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsF
:CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug
:CordovaLib:bundleDebug UP-TO-DATE
:prepareOrgApacheCordovaCordovaLib623DebugLibrary UP-TO-
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources UP-TO-DATE
:processDebugManifest UP-TO-DATE
:processDebugResources UP-TO-DATE
:generateDebugSources UP-TO-DATE
:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:compileDebugJavaWithJavac UP-TO-DATE
:compileDebugNdk UP-TO-DATE
:compileDebugSources UP-TO-DATE
:mergeDebugShaders UP-TO-DATE
:compileDebugShaders UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets
:transformClassesWithDexForDebug UP-TO-DATE
:mergeDebugJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:processDebugJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:validateSigningDebug
:packageDebug
:assembleDebug
:cdvBuildDebug

BUILD SUCCESSFUL

Total time: 2 mins 46.476 secs
Built the following apk(s):

Android studio version: 2.1.1

Kindly, provide me a solution to reduce the gradle build time.


#2

Run cordova build android and cordova build android --debug please.
Is the time needed the same (minus the ~35 seconds for the Ionic build of course)?
If so, this has nothing to do with Ionic but is a pure Cordova thing. You might want to post over at http://issues.cordova.io


#3

cordova build android
ANDROID_HOME=C:\Users\username\AppData\Local\Android
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_112
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated a
at build_b1us5zh0o4kbvz0k2z0f5tp0z.run(C:\Users
The JavaCompile.setDependencyCacheDir() method has been
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint UP-TO-DATE
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:incrementalDebugJavaCompilationSafeguard UP-
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug U
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsF
:CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug
:CordovaLib:bundleDebug UP-TO-DATE
:prepareOrgApacheCordovaCordovaLib623DebugLibrary UP-TO-
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources UP-TO-DATE
:processDebugManifest UP-TO-DATE
:processDebugResources UP-TO-DATE
:generateDebugSources UP-TO-DATE
:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:compileDebugJavaWithJavac UP-TO-DATE
:compileDebugNdk UP-TO-DATE
:compileDebugSources UP-TO-DATE
:mergeDebugShaders UP-TO-DATE
:compileDebugShaders UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:transformClassesWithDexForDebug UP-TO-DATE
:mergeDebugJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:processDebugJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:validateSigningDebug
:packageDebug UP-TO-DATE
:assembleDebug UP-TO-DATE
:cdvBuildDebug UP-TO-DATE

BUILD SUCCESSFUL

Total time: 2 mins 46.029 secs
Built the following apk(s):

cordova build android --debug
ANDROID_HOME=C:\Users\username\AppDa
JAVA_HOME=C:\Program Files\Java\jdk1.8.
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has
at build_b1us5zh0o4kbvz0k2z0f5t
The JavaCompile.setDependencyCacheDir()
Incremental java compilation is an incu
The TaskInputs.source(Object) method ha
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint UP-TO-DATE
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DAT
:CordovaLib:compileDebugShaders UP-TO-D
:CordovaLib:generateDebugAssets UP-TO-D
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-
:CordovaLib:packageDebugRenderscript UP
:CordovaLib:compileDebugRenderscript UP
:CordovaLib:generateDebugResValues UP-T
:CordovaLib:generateDebugResources UP-T
:CordovaLib:packageDebugResources UP-TO
:CordovaLib:processDebugManifest UP-TO-
:CordovaLib:generateDebugBuildConfig UP
:CordovaLib:processDebugResources UP-TO
:CordovaLib:generateDebugSources UP-TO-
:CordovaLib:incrementalDebugJavaCompila
:CordovaLib:compileDebugJavaWithJavac U
:CordovaLib:processDebugJavaRes UP-TO-D
:CordovaLib:transformResourcesWithMerge
:CordovaLib:transformClassesAndResource
:CordovaLib:mergeDebugJniLibFolders UP-
:CordovaLib:transformNative_libsWithMer
:CordovaLib:transformNative_libsWithSyn
:CordovaLib:bundleDebug UP-TO-DATE
:prepareOrgApacheCordovaCordovaLib623De
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources UP-TO-DATE
:processDebugManifest UP-TO-DATE
:processDebugResources UP-TO-DATE
:generateDebugSources UP-TO-DATE
:incrementalDebugJavaCompilationSafegua
:compileDebugJavaWithJavac UP-TO-DATE
:compileDebugNdk UP-TO-DATE
:compileDebugSources UP-TO-DATE
:mergeDebugShaders UP-TO-DATE
:compileDebugShaders UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:transformClassesWithDexForDebug UP-TO-
:mergeDebugJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsFo
:processDebugJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForD
:validateSigningDebug
:packageDebug UP-TO-DATE
:assembleDebug UP-TO-DATE
:cdvBuildDebug UP-TO-DATE

BUILD SUCCESSFUL

Total time: 2 mins 45.537 secs
Built the following apk(s):


#4

Ok, so no difference, right?


#5

Ya… but I am facing this issue after updating to ionic cli 3.0.0


#6

And before?

As I wrote this is not connected to ionic in any way.
Did you also update cordova?


#7

Ya I had updated cordova to v7.0.1


#8

So if the build time changed, it was caused by a change in Cordova CLI or cordova-android. As you are now on 6.2.3 it seems you also updated that.

Did you also update your Android Studio and/or SDK? Then maybe it’s not even Cordova’s fault but just a change in Android.


#9

I solved this issue by downgrading cordova-android to v6.1.2


#10

How long does the Cordova build need there?


#11

It takes only 1 to 3 secs…

cordova build android
:heavy_check_mark: Running command - done!
ANDROID_HOME=C:\Users\username\AppData
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_112
Subproject Path: CordovaLib
Incremental java compilation is an incubating feature.
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint UP-TO-DATE
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:incrementalDebugJavaCompilationSafeguard UP-
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug U
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsF
:CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug
:CordovaLib:bundleDebug UP-TO-DATE
:prepareAndroidCordovaLibUnspecifiedDebugLibrary UP-TO-D
:prepareDebugDependencies
:compileDebugAidl UP-TO-DATE
:compileDebugRenderscript UP-TO-DATE
:generateDebugBuildConfig UP-TO-DATE
:generateDebugResValues UP-TO-DATE
:generateDebugResources UP-TO-DATE
:mergeDebugResources UP-TO-DATE
:processDebugManifest UP-TO-DATE
:processDebugResources UP-TO-DATE
:generateDebugSources UP-TO-DATE
:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:compileDebugJavaWithJavac UP-TO-DATE
:compileDebugNdk UP-TO-DATE
:compileDebugSources UP-TO-DATE
:mergeDebugShaders UP-TO-DATE
:compileDebugShaders UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:transformClassesWithDexForDebug UP-TO-DATE
:mergeDebugJniLibFolders UP-TO-DATE
:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:processDebugJavaRes UP-TO-DATE
:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:validateSigningDebug
:packageDebug UP-TO-DATE
:assembleDebug UP-TO-DATE
:cdvBuildDebug UP-TO-DATE

BUILD SUCCESSFUL