Keywords: Android cmdline-tools historical version, Android cmdline-tools minimum JDK version, JDK corresponding major version, JDK LTS information
Since JDK8 is a commonly used, lower version, you only need to pay attention to the operation of JDK8 and above.
cmdline-tools version and minimum JDK
Final verdict: (On Mac, based on results of JDK8 tests)
cmdline-tools version | SdkManagerCliSettings | AndroidLocationsProvider | Minimum JDK |
---|---|---|---|
11.0 | 61 (JDK 17) | 55 (JDK 11) | 17 |
10.0 | 52 (JDK 8) | 55 (JDK 11) | 11 |
9.0 | 52 (JDK 8) | 55 (JDK 11) | 11 |
8.0 | 52 (JDK 8) | 52 (JDK 8) | 8 |
7.0 | 52 (JDK 8) | 52 (JDK 8) | 8 |
6.0 | 52 (JDK 8) | 52 (JDK 8) | 8 |
As can be seen from the above table, within cmdline-tools, the compilation target JDK versions of various Jars are inconsistent. Therefore, when actually running, the maximum value of the compiled target JDK version of all Jar files needs to be used as the minimum JDK version when cmdline-tools is run.
The latest version of cmdline-tools provided by the Android official website is 11.0 (as of October 24, 2023), which means that the JDK version of its Runtime must be JDK17 and above.
Inspection process
$java-version java version "1.8.0_351" $ cd path/cmdline-tools/9.0/bin $ ./sdkmanager --list Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/prefs/AndroidLocationsProvider has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
It can be seen from the above error message that com/android/prefs/AndroidLocationsProvider
requires at least version 55.0 (JDK 11).
But other classes (such as com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings
in lib/sdklib/libsdkmanager_lib.jar
) are still version 52.0 (JDK 8).
The idea here is:
Directly switch to the corresponding version of cmdline-tools, and then based on the runtime JDK = 8 environment, execute ./sdkmanager --version
to check whether an error is reported. If an error is reported, check the minimum required version. (Below JDK8 is no longer verified)
Verification script: majorVersion.sh
Usage: ./majorVersion.sh path/cmdline-tools/11.0
#!/bin/bash $1/bin/sdkmanager --version $1/bin/sdkmanager --version 2> & amp;1 | grep "class file" jar_file=/lib/sdklib/libsdkmanager_lib.jar echo "-> $jar_file" # Use the javap command to parse the class specified in the JAR file output=$(javap -verbose -classpath "$1${jar_file}" com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings 2> & amp;1) #echo "$output" # Find the major version number major_version=$(echo "$output" | grep 'major version') #Print major version number echo "--> $major_version" ##--- jar_file=/lib/common/tools.common.jar echo echo "-> $jar_file" # Use the javap command to parse the class specified in the JAR file output=$(javap -verbose -classpath "$1${jar_file}" com.android.prefs.AndroidLocationsProvider 2> & amp;1) # Find the major version number major_version=$(echo "$output" | grep 'major version') # # Print major version number echo "--> $major_version"
Validation results:
# 11.0 Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0 -> /lib/sdklib/libsdkmanager_lib.jar major version: 61 -> /lib/common/tools.common.jar major version: 55 #10.0 Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/prefs/AndroidLocationsProvider has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 -> /lib/sdklib/libsdkmanager_lib.jar major version: 52 -> /lib/common/tools.common.jar major version: 55 #9.0 Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/prefs/AndroidLocationsProvider has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 -> /lib/sdklib/libsdkmanager_lib.jar major version: 52 -> /lib/common/tools.common.jar major version: 55 #8.0 -> /lib/sdklib/libsdkmanager_lib.jar major version: 52 -> /lib/common/tools.common.jar major version: 52
Extended information
cmdline-tools historical version
Official website address: https://developer.android.com/studio
cmdline-tools version | Minimum JDK | Mac | Linux | Windows |
---|---|---|---|---|
11.0 (latest) | 17 | commandlinetools-mac-10406996_latest.zip | commandlinetools-linux-10406996_latest.zip | commandlinetools-win-10406996_latest.zip |
10.0 | 11 | commandlinetools-mac-9862592_latest.zip | commandlinetools-linux-9862592_latest.zip | commandlinetools-win-9862592_latest.zip |
9.0 | 11 | commandlinetools-mac-9477386_latest.zip | commandlinetools-linux-9477386_latest.zip | commandlinetools-win -9477386_latest.zip |
8.0 | 8 | commandlinetools-mac-9123335_latest.zip | commandlinetools- linux-9123335_latest.zip | commandlinetools-win-9123335_latest.zip |
Download address generation rules: https://dl.google.com/android/repository/filename
JDK corresponding major version
Java SE 21 = 65 (0x41 hex), Java SE 20 = 64 (0x40 hex), Java SE 19 = 63 (0x3F hex), Java SE 18 = 62 (0x3E hex), (LTS) Java SE 17 = 61 (0x3D hex), Java SE 16 = 60 (0x3C hex), Java SE 15 = 59 (0x3B hex), Java SE 14 = 58 (0x3A hex), Java SE 13 = 57 (0x39 hex), Java SE 12 = 56 (0x38 hex), (LTS) Java SE 11 = 55 (0x37 hex), Java SE 10 = 54 (0x36 hex),[4] Java SE 9 = 53 (0x35 hex),[5] (LTS) Java SE 8 = 52 (0x34 hex), Java SE 7 = 51 (0x33 hex), Java SE 6.0 = 50 (0x32 hex), Java SE 5.0 = 49 (0x31 hex), JDK 1.4 = 48 (0x30 hex), JDK 1.3 = 47 (0x2F hex), JDK 1.2 = 46 (0x2E hex), JDK 1.1 = 45 (0x2D hex).
Source: Java class file
JDK LTS information
- JDK 17(LTS)
- majorversion=61
- Active support: September 30, 2026
- Security support: September 30, 2029
- JDK 11(LTS)
- majorversion=55
- Active support: September 30, 2023
- Security support: September 30, 2026
- JDK 8(LTS)
- majorversion=52
- Active support: March 31, 2022
- Security support: December 31, 2030
source:
- https://endoflife.date/java
- https://www.oracle.com/java/technologies/java-se-glance.html
If you have any suggestions or questions, you can contact me at any time to discuss and learn together:
- Github: likfe
- CSDN: He called himself Mr. Zhang
- Nuggets: cafeting
- Weibo: cafeting