patrickfav / uber-apk-signer

A cli tool that helps signing and zip aligning single or multiple Android application packages (APKs) with either debug or provided release certificates. It supports v1, v2 and v3 Android signing scheme has an embedded debug keystore and auto verifies after signing.
https://favr.dev/opensource/uber-apk-signer
Apache License 2.0
2.01k stars 205 forks source link

class file has wrong version 55.0, should be 53.0 #31

Open Morsmalleo opened 2 years ago

Morsmalleo commented 2 years ago

Keep getting this error everytime I run ./mvnw clean install, the error arises with bothJava 1.8.0_252 and Java 11.0.3 for Kali Linux , done some research and can't seem to find a solution.

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/kali/uber-apk-signer/src/main/java/at/favre/tools/apksigner/ui/MultiKeystoreParser.java:[6,24] cannot access java.util.stream.Collectors
bad class file: /modules/java.base/java/util/stream/Collectors.class
class file has wrong version 55.0, should be 53.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  13.585 s
[INFO] Finished at: 2021-11-09T04:54:32-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project uber-apk-signer: Compilation failure
[ERROR] /home/kali/uber-apk-signer/src/main/java/at/favre/tools/apksigner/ui/MultiKeystoreParser.java:[6,24] cannot access java.util.stream.Collectors
[ERROR]   bad class file: /modules/java.base/java/util/stream/Collectors.class
[ERROR]     class file has wrong version 55.0, should be 53.0
[ERROR]     Please remove or make sure it appears in the correct subdirectory of the classpath.
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
patrickfav commented 2 years ago

Class file version 53 is Java 9 and version 55 is java 11 - are you sure you set Maven to use the desired java version and not just java home?

Try to run ./mvnw -version to see which java version it uses. Mine is

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Users\****\.m2\wrapper\dists\apache-maven-3.6.3-bin\1iopthnavndlasol9gbrbg6bf2\apache-maven-3.6.3
Java version: 1.8.0_202, vendor: AdoptOpenJdk, runtime: C:\Program Files\AdoptOpenJDK\jdk-8.0.202.08\jre
Default locale: de_AT, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

and compiles fine.

Morsmalleo commented 2 years ago

Ah so that's what the problem could be, I will run the command in the terminal and print the output

Morsmalleo commented 2 years ago

OK so I ran ./mvnw -version in a terminal and this was the output

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/kali/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
Java version: 11.0.13, vendor: Debian, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.10.0-kali9-amd64", arch: "amd64", family: "unix"

I switched to Java 1.8.0_252 provided by the Debian Stretch software repositories and ran the same command and it gave me the same output.

LynnLiu301 commented 2 years ago

Any solution on this problem? I am running into same thing on my gradle project.

Morsmalleo commented 2 years ago

Any solution on this problem? I am running into same thing on my gradle project.

Nothing so far bro, been waiting for a while, not sure what's happening

ShemBrooklyne commented 2 years ago

Any solution on this problem? I am running into same thing on my gradle project.

Nothing so far bro, been waiting for a while, not sure what's happening

I sort of encountered a similar issue today and I have managed to solve it with help from multiple sources from the internet. I learned that the issue is that some class files were compiled using Java X while others were compiled using Java Y.

  1. Your first approach is to confirm the linked Java version of your mvn. mvn -v
  2. Then confirm which Java version you are using for both your computer and application.
  3. If they don't match, feel free to set a JAVA_HOME variable for your desired Java version. echo export "JAVA_HOME=\$(/usr/libexec/java_home -v 17)" >> ~/.bash_profile && source ~/.bash_profile
  4. After that, do a maven build of your application. mvn clean install
Morsmalleo commented 2 years ago

Thanks I'll give this a try

keunoh commented 1 year ago

Because the library classes that you're using at the moment are decompiled by Java 11, not different verison of Java. When I check some parent class from some library, it updated by Java version. I mean classes are changing depends on Java version. So you need to match library classes that you use and Java version.

Morsmalleo commented 1 year ago

Because the library classes that you're using at the moment are decompiled by Java 11, not different verison of Java. When I check some parent class from some library, it updated by Java version. I mean classes are changing depends on Java version. So you need to match library classes that you use and Java version.

I didn't think Java 9 had an installation candidate because that's what class file 53 is, it's java 9