For general android development, should I use jdk7...
# android
s
For general android development, should I use jdk7 or jdk8?
u
I prefer jdk8 It has many new features like lambda expression etc
s
I mostly like newer versions, but I am concerned about incompatibilities or devices only running Java 7 -> resulting in my Java 8 app being not able to run.
u
Android app depends on SDK version not JDK Also the Android studio has built in jdk8 in new version Can you provide an example Android device that has jdk7 and not compatible with jdk8
s
@Umar Ata So you're effectively saying I could just use Java 16 or 17 with all it's new features and just expect it to compile properly to the dex files?
u
I haven't said that, I said you could use jdk8 with your app For JDK higher than 8 depends on compilation For sometime back I was using jdk15 and it was causing more compilation time and have some syntax error also due to version of jdk used in libraries not supported the new JDK But yes if you are able to compile and generate apk from any higher version like you mentioned 16 it should work
m
The latest version of Android studio ships with JDK 11 and you should target Java 8. If you minimum SDK level is below the level where 8 became standard, must of the Java 8 functionality will be back ported by the android gradle plugin. Instructions on how to configure gradle to do that back port. https://developer.android.com/studio/write/java8-support
For most of Kotlin, you don't need to use the desuraging, but you do if you use the kotlinx.datetime library. Other third part libraries might require it also.