I know I can choose the SDK location in Android Studio's Project Structure.
I have two questions:
Why do we need JDK when we are already using Android SDK? After all, we are not developing for JVM.
Is there any difference between using JDK 1.6, 1.7 and 1.8?
Why do we need JDK when we are already using Android SDK? After all, we are not developing for JVM.
The Android build process depends on a number of tools from the JDK. Check out the build system overview documentation.
The first big piece we need from JDK is javac
- all your source code written in Java needs to be compiled before it can be converted to the DEX foramt.
Once your code has been compiled, dexed, and packaged into an APK, we need jarsigner
to sign the APK.
Is there any difference between using JDK 1.6, 1.7 and 1.8? That depends on what features you are using from each. Older projects that don't use Java 7 features can use Java 6 without issue. I personally recommend Java 7 for most modern projects. If you can use it, why not?
There are some efforts out there to bring Java 8 features to Android, most notably gradle-retrolambda. Some of these require JDK 8 to compile properly.
Android always supported Java 6.
Android now support Java 7 so that is the recommended one (since KitKat).
Android does not support Java 8 as of yet.
You can specify Java 7 like so in your build.gradle file:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
The only difference being the Java version (Java 7 adds features of course) and the fact that Android does not support Java 8 period.
EDIT
Actually this was answered here: Which JDK version (Language Level) is required for Android Studio?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With