2

I've upgraded Android Studio 3.x to 3.4 (with Grade plugin), and now, the build of my project is very very very long, and there is a final error (after 4-5mins of building):

> Task :app:compileDevelopmentDebugJavaWithJavac
Gradle may disable incremental compilation as the following annotation processors are not incremental: butterknife-compiler-10.1.0.jar (com.jakewharton:butterknife-compiler:10.1.0), esperandro-2.6.0.jar (de.devland.esperandro:esperandro:2.6.0).
Consider setting the experimental feature flag android.enableSeparateAnnotationProcessing=true in the gradle.properties file to run annotation processing in a separate task and make compilation incremental.
Note: [1] Wrote GeneratedAppGlideModule with: [com.bumptech.glide.integration.okhttp3.OkHttpLibraryGlideModule]
warning: No SupportedSourceVersion annotation found on de.devland.esperandro.processor.EsperandroAnnotationProcessor, returning RELEASE_6.
warning: Supported source version 'RELEASE_6' from annotation processor 'org.gradle.api.internal.tasks.compile.processing.TimeTrackingProcessor' less than -source '1.8'


The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: GC overhead limit exceeded
    at java.lang.StringCoding$StringEncoder.encode(StringCoding.java:300)
    at java.lang.StringCoding.encode(StringCoding.java:344)

Before this upgrade (done this morning), all works perfectly. Have you got some investigation ways please?

build.gradle:

buildscript {
    repositories {
        google()

        jcenter()
    }

    dependencies {
        // https://developer.android.com/studio/releases/gradle-plugin.html
        classpath 'com.android.tools.build:gradle:3.4.0'

        // https://developers.google.com/android/guides/google-services-plugin
        classpath 'com.google.gms:google-services:4.2.0'

        classpath 'com.google.firebase:firebase-plugins:1.2.0'

        // https://github.com/JakeWharton/butterknife
        classpath 'com.jakewharton:butterknife-gradle-plugin:10.1.0'
    }
}

gradle-wrappers.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
anthony
  • 7,653
  • 8
  • 49
  • 101

2 Answers2

0

Increase the memory available to Gradle build system.

Put this in your gradle.properties file:

org.gradle.jvmargs=-Xmx2g

mx means max memory, 2g means two gigabytes.

If there already is a org.gradle.jvmargs add -Xmx2g at the end. Remove the old -Xmx if there is any.

You shouldn't need more than three gigabytes for your app. Adding more gigabytes doesn't necessarily give better performance.

Eugen Pechanec
  • 37,669
  • 7
  • 103
  • 124
0

Try options.forkOptions.setMemoryMaximumSize("2g") if you are also using options.fork.

For me, org.gradle.jvmargs or javaMaxHeapSize does not work. So I commented out lots of gradle script commands to diagnose which cause the problem, and found options.fork.

ps. Removing options.fork also works.

Dot Cink
  • 381
  • 2
  • 12