pxb1988 / dex2jar

Tools to work with android .dex and java .class files
Apache License 2.0
12.26k stars 2.1k forks source link

Upgrading to 2.2 SNAPSHOT giving below error, Same JDK is working fine with SNAPSHOT 2.1 #525

Closed vramasam closed 2 years ago

vramasam commented 2 years ago

Hello @ThexXTURBOXx

The issue is not happened with 2.1 SNAPSHOT jars, issue is happening only when we try to upgrade 2.2 SNAPSHOT jars

[dex2jar-2.0]$ ./d2j-dex2jar.sh -f -o /tmp/classes.jar /tmp/classes.dex dex2jar /tmp/classes.dex -> /tmp/classes.jar Exception in thread "main" java.lang.NoSuchMethodError: java/nio/ByteBuffer.position(I)Ljava/nio/ByteBuffer; (loaded from /usr/java/jdk1.8.0_311/jre/lib/rt.jar by ) called from class com.googlecode.d2j.reader.DexFileReader (loaded from file:/u001/apache-tomcat-8.5.73_9980/assets/dex2jar-2.0/lib/dex-reader-2.2-SNAPSHOT.jar by sun.misc.Launcher$AppClassLoader@c84dacb6). at com.googlecode.d2j.reader.DexFileReader.(DexFileReader.java:152) at com.googlecode.d2j.reader.DexFileReader.(DexFileReader.java:262) at com.googlecode.d2j.reader.MultiDexFileReader.open(MultiDexFileReader.java:37) at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java:108) at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:290) at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:33)

@ThexXTURBOXx Can you please help here what can be the issue?

ThexXTURBOXx commented 2 years ago

The problem is that the dex2jar version you are trying to run is compiled using a newer version of the JDK whee the signature of the ByteBuffer#position method is changed. Are you using my builds or the snapshot one from pxb1988?

vramasam commented 2 years ago

Yes @ThexXTURBOXx . Got the issue. I have taken the source code and build the source code with Java 11 and tried to use it in the Java 8 build machine. That is the root cause for the issue. Thank you for the support.

ThexXTURBOXx commented 2 years ago

Okay, no problem! Yes, that is indeed an annoying issue and there is not really a good way around that. You could use reflection, but it is rather ugly to do so. Just compile and run dex2jar using the same JDK everytime :)