Use JDK 8 to prevent OOM during Gradle builds

Recently, I've run into OutOfMemoryError: PermGen space issue when building Gradle projects, especially with Kotlin.

A common way to fix that is to increase the heap size for Gradle JVM, like adding org.gradle.jvmargs=-XX:MaxPermSize=512m to grade.properties.

Actually, there's another simple way to fix the issue which is using JDK 8 because it eliminates the PermGen space. More details can be found at Java 8: From PermGen to Metaspace or this StackOverflow answer.

Notes to Android developers, even though JDK 8 hasn't been supported by Android, but you can still use JDK 8 to build Android projects as long as you set compatibility level to 6 or 7 depends on minSDKVersion. Then you will get benefits like what we mentioned earlier.