'Which Java version is the fastest on and is supported by Android?
I heard that Java is becoming faster on newer versions of Android that it's almost as fast as C++, and the performance depends on the type of code/operations. Is this true? If it is, which Java version is the fastest on Android and is supported for Android development?
I currently probably have Java 11; it said so when I entered java --version
into CMD:
java 11.0.11 2021-04-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.11+9-LTS-194)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.11+9-LTS-194, mixed mode)
But, I got this when I opened the "About Java" app:
Would the upgrade be worth it, and is it different from Java 8/11 in how it builds/syntax/features? Would changing the Java/JDK version affect the Gradle/other build tools' versions or the minimum Android version a device would need to run my apps?
Also, if there's any difference in the speed/performance between using different compilers, JDKs and optimizations, how faster/better is it?
Any comparisons would be helpful.
Solution 1:[1]
I heard that Java is becoming faster on newer versions of Android that it's almost as fast as C++,
The Java platform has had performance around that of C++ for a couple decades. Sometimes faster, due to the dynamic runtime optimizations made by HotSpot or OpenJ9.
?? But Android does not run the Java platform.
When writing Android code in either the Kotlin language or the Java language, that code is compiled down to Dalvik bytecode. At runtime, that byte code is further interpreted/compiled by the Android Runtime in modern Android, or by the Dalvik Runtime in earlier Android.
which Java version is the fastest on Android and is supported for Android development?
Your choice of JDK and Java version will not affect the performance of your Android app. As explained above, the JDK is not involved with the runtime execution of your Android app.
Would the upgrade be worth it, and is it different from Java 8/11 in how it builds/syntax/features?
You can make use of some of the new Java language features found in later versions of Java. See links below.
I wouldn't want to simply install different Java versions and change Android Studio's settings.
You can certainly install multiple JDKs on your machine. For installing and managing multiple JDKs, I suggest using SDKMAN.
Within Android Studio, in your project's settings, you specify which of the installed JDKs to utilize. See Set the JDK version section in the manual.
?? Note however that the documentation recommends using the JDK that comes bundled with Android Studio.
For more info, use the links provided by CommonsWare:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |