I currently have Java 7 JDK installed. It's been like that for awhile. However, recently, my professor is instructing the class to uninstall Java JDK 7 and install Java JDK 8 instead to be able to work on homework and such.
I've been using Java JDK 7 to write and deploy Android apps without any problems so I'm wondering if it's safe to make the upgrade now the JDK 8? I'm assuming that I won't be needing any Java 8 specific methods or functions in my Android development. So if I stay away from that, will my Android development be at all affected?
On a side note, I haven't been able to find any official documentation that states whether or not Java JDK 8 is safe or not or how to make it safe. Either way, I'm going to have to upgrade to Java 8 soon...
Java 8 has been supported natively since Android SDK 26. If you wish to use Java 8 language features and your minimal SDK version is lower than 26, . class files produced by the javac compiler need to be converted to bytecode that is supported by these SDK versions.
Yes. Absolutely. Java is still 100% supported by Google for Android development. The majority of Android apps today have some mix of both Java and Kotlin code.
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. (If you are certain that you already have JDK 1.8 or higher on your computer, such as from taking CS 106A, you can skip to Step 2.)
In Google I/O 2016, they announced that Android now supports some features of Java 8, but not all the features.
Features like
Additionally, the following Java 8 language APIs are also available:
java.lang.FunctionalInterface
java.lang.annotation.Repeatable
java.lang.reflect.Method.isDefault()
AnnotatedElement.getAnnotationsByType(Class)
java.util.function
java.util.stream
All what you should do is to use the new jack compiler, to do this you have just to add this to your gradle file build.gradle (Module: app)
:
android {
...
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
References:
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