Android Studio Gradle Build takes more than 5 minutes

前端 未结 3 943
梦如初夏
梦如初夏 2021-02-04 06:11

So I have been working on a simple app in Android Studio and since last couple of days, whenever I click \"Run\", it takes more than 5 minutes to build. It didn\'t used to be th

3条回答
  •  自闭症患者
    2021-02-04 06:34

    Other solutions here have not helped me yet. I am seeing builds lasting 30+ minutes only to end with Error:Out of memory: GC overhead limit exceeded. But I have made slight progress the past few days.

    Note: I do not believe this is a solution to the problem, just a workaround until Jack works out the kinks

    I added the following to my build gradle:

    android {
        ....
      defaultConfig {
        ....
        jackOptions {
                enabled true
                additionalParameters('jack.incremental': 'true')
            }
        }
    
        compileOptions {
            incremental true
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    
        dexOptions {
            javaMaxHeapSize '4096m'
        }
    

    }

    For some reason, adding

    org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 
    

    to my gradle.properties made no difference. I had to add it in the dexOptions.

提交回复
热议问题