Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is JDK 1.8 fully supported by Android Studio?

Tags:

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.

like image 604
Madona wambua Avatar asked Jul 21 '15 01:07

Madona wambua


People also ask

Which version of JDK is compatible with Android Studio?

Set the JDK version A copy of the latest OpenJDK comes bundled with Android Studio 2.2 and higher, and this is the JDK version we recommend you use for your Android projects.

Can I use Java 8 in Android Studio?

Java 8 language features are now supported by the Android build system in the javac/dx compilation path. Android Studio's Gradle plugin now desugars Java 8 class files to Java 7-compatible class files, so you can use lambdas, method references and other features of Java 8.

Can JDK run on Android?

Since Android apps are written in Java, you will need the Oracle Java compiler and libraries on your system. These are collectively called the Java Development Kit or "JDK" for short.

Which version of Java is used for Android?

Class libraryJava 8 source code that works in latest version of Android, can be made to work in older versions of Android.


2 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"  } 
like image 194
Rakshit Soni Avatar answered Sep 28 '22 01:09

Rakshit Soni


You should just use JDK 1.7. There are some features in JDK 8 that are not yet supported.

like image 25
d0nut Avatar answered Sep 28 '22 02:09

d0nut