[Android-tools-devel] Bug#925320: android-platform-tools-apksig: apksigner fails to run on OpenJDK 8 due to UnsupportedClassVersionError

Tiago Stürmer Daitx tiago.daitx at canonical.com
Sat Mar 23 00:48:47 GMT 2019


Package: android-platform-tools-apksig
Version: 0.8-2
Severity: important

Dear Maintainer,

The apksigner binary from android-platform-tools-apksig 0.8-2 fails to
run under OpenJDK 8 because it is not being targetted to java 8 level.

Please note that if OpenJDK 11 is installed it will be used instead even
if the system is set to use OpenJDK 8 binaries by default, so if trying
to reproduce this make sure that *only* OpenJDK 8 runtime is installed.

The error is:
$ apksigner
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool 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
 at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
 at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
 at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
 at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

The fix is to replace the '-source 8' entry with '--release 8' in the
rules file. While adding '-target 8' would also work, using '--release'
is better as it also sets the right '-bootclasspath' without much fuzz.

Regards,
Tiago

-- System Information:
Debian Release: buster/sid
  APT prefers disco
  APT policy: (500, 'disco'), (400, 'disco-proposed')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-13-generic (SMP w/4 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled



More information about the Android-tools-devel mailing list