Gradle build devibug and preDexDebug using CircleCI

I tried to use assembleDebug using CircleCI, but it should not create (preDex). Why can't I do this?

  • Using ProductFlavor (the name is production)
  • Android Gradle ver.1.1.0-rc1

Problem

./gradlew assembleProductionDebug passed away unexpectedly Building 92% 3%>: application: preDexProductionDebugaction./gradlew assembleProductionDebug failed

circle.yml

 general: artifacts: - "app/build/outputs/apk/app-production-release-unaligned.apk" machine: java: version: openjdk7 environment: ANDROID_HOME: /usr/local/android-sdk-linux dependencies: pre: - echo y | android update sdk --no-ui --all --filter "build-tools-21.1.2" - echo y | android update sdk --no-ui --all --filter "platform-tools" - echo y | android update sdk --no-ui --all --filter "tools" - echo y | android update sdk --no-ui --all --filter "extra-google-google_play_services" - echo y | android update sdk --no-ui --all --filter "extra-google-m2repository" - echo y | android update sdk --no-ui --all --filter "extra-android-m2repository" - echo y | android update sdk --no-ui --all --filter "extra-android-support" - echo y | android update sdk --no-ui --all --filter "android-21" - git submodule sync - git submodule update --init cache_directories: - ~/.android - ~/android override: - ./gradlew dependencies test: override: - ./gradlew test deployment: master: branch: master commands: - ./gradlew assembleProductionDebug 
+6
source share
3 answers

I had the same problem. It turned out that I had to disable preDex to build ci.

Put it in the root build.gradle :

 project.ext.preDexLibs = !project.hasProperty('disablePreDex') subprojects { project.plugins.whenPluginAdded { plugin -> if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) { project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs } else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) { project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs } } } 

Then you can build the following command on your ci:

 ./gradlew ... -PdisablePreDex 
+8
source

Thus, I had the same problem and I found that even if the java and gradle heap sizes were set, they were not fully respected, since dex tasks generate a lot of fresh threads with their own heap size (check the memory log and you can see that same) If so, the method that I used to install it for Android gradle plugin 1.3 and above should have used:

 -Pcom.android.build.threadPoolSize=1 

This will stop the dexing step, creating a bunch of fresh 1G streams. There is also:

 -Porg.gradle.parallel=false 

But I found this to be inefficient when using multidex for some reason. For CircleCI, I found this to be the most consistent build task if it is a bit slow. I am sure heap sizes can be improved to improve results:

 ./gradlew build -PpreDexEnable=false -Pcom.android.build.threadPoolSize=1 -Dorg.gradle.parallel=false -Dorg.gradle.jvmargs="-Xms512m -Xmx512m" -Dorg.gradle.daemon=false 
+5
source

I had the same problem, it was caused with memory limitations per container (this is 4 GB). For me, the solution was to use: gradle.properties

 org.gradle.jvmargs=-Xms256m -Xmx2048m 
+1
source

Source: https://habr.com/ru/post/982204/


All Articles