Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GC overhead limit exceeded when enable R8 Shrinker in Android Studio

Tags:

I'm using Android Studio 3.4 (Canary 9), when I build my app, it failed with the following error

Task :app:transformClassesAndResourcesWithR8ForDebug

R8 is an experimental feature. If you experience any issues, please file a bug at https://issuetracker.google.com, using 'Shrinker (R8)' as component name. You can disable R8 by updating gradle.properties with 'android.enableR8=false'.

AGPBI: {"kind":"warning","text":"Missing class: java.lang.instrument.ClassFileTransformer","sources":[{}],"tool":"D8"}

Task :app:transformClassesAndResourcesWithR8ForDebug FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformClassesAndResourcesWithR8ForDebug'.

GC overhead limit exceeded

When I disable R8 by putting android.enableR8=false into gradle.properties. Everything is working fine.

So how can I fix this error without disable R8 Shrinker? Because I'm really want to test functionality of R8.

like image 231
nhoxbypass Avatar asked Jan 12 '19 17:01

nhoxbypass


People also ask

How do I fix GC overhead limit exceeded in eclipse?

From the root of the Eclipse folder open the eclipse. ini and change the default maximum heap size of -Xmx256m to -Xmx1024m on the last line. NOTE: If there is a lot of memory available on the machine, you can also try using -Xmx2048m as the maximum heap size.


1 Answers

As you said you are not using any custom JVM args, try it out.

In your gradle.properties file try several values for memory settings. For example try to set

org.gradle.jvmargs=-Xmx4096m 

As suggested by the commented section:

Specifies the JVM arguments used for the daemon process.

The setting is particularly useful for tweaking memory settings.

org.gradle.jvmargs=-Xmx1536m

I've used R8 in my project and all worked fine.

like image 95
shadowsheep Avatar answered Sep 28 '22 21:09

shadowsheep