I just downloaded JDK 1.8.0_51 from my previous JDK 1.8.0_33 because i was having issues. There being some workaround to use Jdk 8 with Android, I was just wondering has Google already added a full support to the JDK in Android studio ? or should I just use JDK 1.7? advice will be highly appreciated.
-
2I have Java 8 only and Android Studio here. No problem so far. But don't use (When developing Android App) Java 8's feature like Lambda. It will not work yet. – Glenn Jul 21 '15 at 11:54
8 Answers
you can now use java8 with android
add this lines in you build.gradle file
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
refer this doc http://developer.android.com/intl/es/preview/j8-jack.html
Make sure to enable Jack as well with:
android {
//...
defaultConfig {
//...
// Required to use Java 8.
jackOptions {
enabled true
}
}
Additionally, you will need to be using version 24 or greater of the Android SDK Build Tools:
android {
//...
buildToolsVersion "25.0.2"
}

- 45,245
- 23
- 243
- 245

- 1,347
- 3
- 20
- 27
-
2not only can you use java8 now, but it is required for API 24 (Nougat) or newer – yuval Aug 10 '16 at 01:32
-
jackOptions are deprecated. See: https://developer.android.com/studio/write/java8-support – Redwolf Jan 18 '19 at 15:59
You should just use JDK 1.7. There are some features in JDK 8 that are not yet supported.

- 2,835
- 1
- 18
- 23
-
1@JoshPinter You can use JDK 8 but, unless your android app targets SDK 23 and higher, there is no need to use JDK 8. Java 8 _can_ be used if you enable 'Jack and Jill' but, like I said, that requires a _minimum_ target of 23. – d0nut Mar 01 '17 at 19:29
-
Thanks. I went down that route and ran into issues with Jack and Jill causing my app to crash. Had to increase the heap size and a bunch of other things, too. It was decidedly not worth it. :) – Joshua Pinter Mar 01 '17 at 22:58
-
@JoshPinter What I recommend, if you want to use something a little more modern, is just write your application in Kotlin. It is 100% completely interoperable with Java and gives you things like lambdas which make writing the application a more pleasant experience. The language itself is a lot more like Swift than Java and is used by JetBrains to build their IDEs from my understanding. Very stable. – d0nut Mar 02 '17 at 02:39
-
1Great, thanks for the tip. I've read and watched a lot about Kotlin. I'm mostly developing in React Native these days but if end up doing a lot of native work, I'll take a look at it. – Joshua Pinter Mar 02 '17 at 02:43
Using JDK 1.8 is OK and nothing will bother you except Android Studio may often provide runtime check for you to suggest you using JDK 1.8's feature like lambda. But you can go to Settings->Editor->Inspections->Java language level issues/migration aids and close what you want.

- 11,573
- 7
- 37
- 53
You can use java 1.8 but dont use 1.8 feature because there are some feature in Java 1.8 which are not supported by now.

- 6,200
- 6
- 45
- 64
-
3for example, I don't believe java.time is supported in Android Studio. – JDOaktown Feb 25 '16 at 00:02
If you previously used JACK options, which are deprecated from Android Studio 3.0.0, migrating and using the supported Java 8 language features would be as simple as removing:
jackOptions { enabled true }
from the app's build.gradle file and keepping the configuration as follows:
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
For details follow this link.

- 2,661
- 5
- 31
- 39
Use Java 1.7 or Java 1.6 I had problems by my self with Android 4 and Java 7 so I used 1.6 and all problems where gone.
I think you will got less problems when you use 1.7 instead of 1.8

- 69
- 9
I started getting this error after java update to 1.8
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\whatever\AppData\Local\Android\sdk\build-tools\23.0.1\aapt.exe'' finished with non-zero exit value 1

- 486
- 11
- 20
-
If i get this finished with non-zero exit value 1, i always go to Build and (clean project). Always solves the issue for me. – Madona wambua Feb 25 '16 at 14:36
-
Thanks for reply but that didnt help I had to get back to java 1.7 finally – Lakhwinder Singh Dhillon Feb 28 '16 at 03:57
Actually you get all sorts of crazy Gradle errors when trying to build Android Studio projects with Java 8, like
2016-04-10 17:50:49,401 [1624477] WARN - nal.AbstractExternalSystemTask - Gradle 2.10 requires Java 6 or later to run. Your build is currently configured to use Java 5. com.intellij.openapi.externalSystem.model.ExternalSystemException: Gradle 2.10 requires Java 6 or later to run. Your build is currently configured to use Java 5.
As soon as I switched the default JDK to Java 7 it works fine. Looks like running Android Studio itself with Java SE 8 is tolerated, but building Android apps via Gradle with it only works well with Java 7.

- 592
- 5
- 12