Reputation:
I am getting Error:UNEXPECTED TOP-LEVEL. The log shows to increase the heap size. I have added android:largeHeap = true in an application. Then also I am getting this error.
Manifest:
<application
android:allowBackup="true"
android:name="android.support.multidex.MultiDexApplication"
android:icon="@drawable/icon1"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">
Log:
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB.
To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
Error:UNEXPECTED TOP-LEVEL ERROR:
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
Error: at java.util.Arrays.copyOf(Arrays.java:3236)
Error: at java.io.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:191)
Error: at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:279)
Error: at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
Error: at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
Error: at com.android.dx.command.dexer.Main.processOne(Main.java:672)
Error: at com.android.dx.command.dexer.Main.processAllFiles(Main.java:569)
Error: at com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)
Error: at com.android.dx.command.dexer.Main.run(Main.java:275)
Error: at com.android.dx.command.dexer.Main.main(Main.java:245)
Error: at com.android.dx.command.Main.main(Main.java:106)
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit value 3
Information:BUILD FAILED
Information:Total time: 7 mins 31.106 secs
Information:14 errors
Information:0 warnings
Information:See complete output in console
What to do?
Upvotes: 2
Views: 6141
Reputation: 1279
Your log:
To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties
Upvotes: 0
Reputation: 493
The log says
"To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties."
So open your gradle.properties file and add the line "org.gradle.jvmargs=-Xmx2048M"
Upvotes: 4
Reputation: 1544
In your build.gradle
Try to add this :
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
incremental true
is using to speed up your builds.javaMaxHeapSize "4g"
to specify the heap size for the dex process.Upvotes: 3