Gradle Too Long

Gradle Now build takes too long (literally it doesn't finish after running for 1 hour) after enabling MultiDex. I followed the steps given at https://developer.android.com/studio/build/multidex.html to set up MultiDex in the app.

Below is a snippet of my gradle console.

:app:compileDevelopmentDebugNdk UP-TO-DATE
:app:compileDevelopmentDebugSources
:app:mergeDevelopmentDebugShaders UP-TO-DATE
:app:compileDevelopmentDebugShaders UP-TO-DATE
:app:generateDevelopmentDebugAssets UP-TO-DATE
:app:mergeDevelopmentDebugAssets UP-TO-DATE
:app:unzipJacocoAgent UP-TO-DATE
:app:transformClassesWithJacocoForDevelopmentDebug UP-TO-DATE
:app:transformClassesWithDexForDevelopmentDebug

      

The last task :app:transformClassesWithDexForDevelopmentDebug

is the one that stops the gradle console. Any help would be greatly appreciated. I also need to test the app on pretreatment devices.

Edit

The problem only occurs when I test my app on a pre-Lellipop test device. It looks like the building for the main test device is working fine. The Nexus 6P takes 8.12 seconds. But I also want to test pre-petal devices.

Edit 2

As per @Gillis advice I am attaching my glass trace

10:19:10.558 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
10:19:10.558 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
10:19:10.559 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
10:19:10.559 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
10:19:10.559 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
10:19:10.559 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
10:19:10.559 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
10:19:20.555 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
10:19:20.560 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
10:19:20.560 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
10:19:20.561 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
10:19:20.561 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
10:19:20.561 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
10:19:20.561 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.

      

I tried to delete my folder /home/.gradle

but still no luck. It is clear that there is a loop in the lock.

Also I also add my jstacktrace

"File lock request listener" #27 prio=5 os_prio=31 tid=0x00007fb9b2c20800 nid=0x5d07 runnable [0x0000700001961000]
   java.lang.Thread.State: RUNNABLE
        at java.net.PlainDatagramSocketImpl.receive0(Native Method)
        - locked <0x00000006c026d670> (a java.net.PlainDatagramSocketImpl)
        at java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:143)
        - locked <0x00000006c026d670> (a java.net.PlainDatagramSocketImpl)
        at java.net.DatagramSocket.receive(DatagramSocket.java:812)
        - locked <0x00000006c0bc5df0> (a java.net.DatagramPacket)
        - locked <0x00000006c026d630> (a java.net.DatagramSocket)
        at org.gradle.cache.internal.FileLockCommunicator.receive(FileLockCommunicator.java:60)
        at org.gradle.cache.internal.locklistener.DefaultFileLockContentionHandler$1.doRun(DefaultFileLockContentionHandler.java:67)
        at org.gradle.cache.internal.locklistener.DefaultFileLockContentionHandler$1.run(DefaultFileLockContentionHandler.java:54)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

      

refer to this pastebin for the complete log.

+2


source to share


6 answers


Thanks for your appreciation. I solved this problem. Apparently the problem was that (I suppose) JaCoCo was dexing along with my dexing class and releasing locks. I fixed this by removing the line testCoverageEnabled=true

in my build.gradle app.



In case any of you encounter a similar problem. Create two build styles (prod and development) and add a testCoverageEnable=true

development flavor only line and set it to false else where. Also make sure your development is set minSdkVersion

to 21 (Lollipop) as dexing is done for ART and you generally won't run into this issue.

+4


source


Besides all the gradle tweets given in the other answers, you can also do something like terminate the gradle process. In my experience this and starting a new build fix the problem.



+1


source


go to application folder in console and run:

./gradlew build --debug

it gives you a lot of information about what will go wrong. usually when gradle freezes, it is caused by an external dependency that cannot be recovered.

You can try enabling offline mode in Android studio to see if this is indeed the problem.

+1


source


try it

    android {
        compileSdkVersion 24
        buildToolsVersion "24.0.0"

        dexOptions {
            javaMaxHeapSize "4g"
        }
        ....
    }

      

0


source


Make sure your gradle is modern android studio first. After the update, delete the invalid cache and restart and then in the Global gradle Setting check "Work Offline", its working for I also give it a try. enter image description here

0


source


A few tips to increase your Gradle runtime performance:

Gradle Daemon You can reduce the startup time of Gradle s (on my computer to two seconds) if you tell Gradle to use the build daemon:

org.gradle.daemon=true

      

Running parallel projects This can make a big difference if you are building a very complex project with many submodule dependencies:

org.gradle.parallel=true

      

Global gradle.properties

Properties defined in a properties file in our home directory take precedence over properties defined in a file in our projects directory. The reason for this is that you want to avoid using the Gradle daemon on build servers where startup time is less important than memory consumption:

/Users/~/.gradle/gradle.properties

      

like this

0


source







All Articles