Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Infinite Gradle Build Running Java 8

I try to migrate from Java 7 to Java 8, so I have install the new sdk for Android N and all tools. I follow the developper guide to use Java 8 in android studio, but when i try to compile apk, I have an infinite Gradle Build Running.. I already try to restart Android Studio, but after 1 hour, the Gradle Build Running it's not finished. In the Windows task manager I see the process java.exe take a lot of memory and CPU was at 90%.

Someone already encountered this problem ?

Thanks.

Edit:

I have the following versions :

Java version : 1.8.0_92
Gradle version : 2.1.2
Android Studio version : 2.1.2

compileSdkVersion : 24
buildToolsVersion : 24

targetSdkVersion : 24

Edit2:

I tried with Android Studio 2.2 and 5 minutes after starting the build, I have this error :

Error:Execution failed for task ':app:compileProductionDebugJavaWithJack'. 
> java.lang.RuntimeException: java.lang.OutOfMemoryError: GC overhead limit exceeded
like image 614
Johann67 Avatar asked Oct 18 '22 07:10

Johann67


2 Answers

add these lines to your gradle.properties file

org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home //edit this according to your java home path

org.gradle.daemon=true

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

org.gradle.parallel=true

org.gradle.configureondemand=true
like image 118
nzackoya Avatar answered Nov 01 '22 16:11

nzackoya


When you run Android Studio for the first time, it will download some initial plugins and the delay depends on the internet connection speed and some other things. But you may want to run the IDE in offline mode. To do so, go to File -> Settings and then 'Build, Execution, Deployment' -> 'Build Tools' -> 'Gradle' and enable 'Offline work' checkbox.

Sorry, I couldn't comment this because of low reputation :D

like image 31
JamesNickel Avatar answered Nov 01 '22 16:11

JamesNickel