For general android development, should I use jdk7 or jdk8?
u
Umar Ata
05/17/2021, 11:55 AM
I prefer jdk8
It has many new features like lambda expression etc
s
spnda
05/17/2021, 11:57 AM
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
Umar Ata
05/17/2021, 11:59 AM
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
spnda
05/17/2021, 12:23 PM
@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
Umar Ata
05/17/2021, 12:26 PM
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
mkrussel
05/17/2021, 1:40 PM
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
mkrussel
05/17/2021, 1:41 PM
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.