bytecode-viewer icon indicating copy to clipboard operation
bytecode-viewer copied to clipboard

Code decompilation fails in 2.10.12

Open JimiSmith opened this issue 3 years ago • 9 comments

2.9.22 is able to decompile the code, but 2.10.12 throws an exception

com.googlecode.d2j.DexException: fail convert code for Landroidx/constraintlayout/solver/widgets/ConstraintWidget;.applyConstraints(Landroidx/constraintlayout/solver/LinearSystem;ZZZZLandroidx/constraintlayout/solver/SolverVariable;Landroidx/constraintlayout/solver/SolverVariable;Landroidx/constraintlayout/solver/widgets/ConstraintWidget$DimensionBehaviour;ZLandroidx/constraintlayout/solver/widgets/ConstraintAnchor;Landroidx/constraintlayout/solver/widgets/ConstraintAnchor;IIIIFZZZZZIIIIFZ)V
	at com.googlecode.d2j.dex.ExDex2Asm.convertCode(Unknown Source)
	at com.googlecode.d2j.dex.Dex2jar$2.convertCode(Unknown Source)
	at com.googlecode.d2j.dex.Dex2Asm.convertMethod(Unknown Source)
	at com.googlecode.d2j.dex.Dex2Asm.convertClass(Unknown Source)
	at com.googlecode.d2j.dex.Dex2Asm.convertDex(Unknown Source)
	at com.googlecode.d2j.dex.Dex2jar.doTranslate(Unknown Source)
	at com.googlecode.d2j.dex.Dex2jar.to(Unknown Source)
	at the.bytecode.club.bytecodeviewer.util.Dex2Jar.dex2Jar(Dex2Jar.java:44)
	at the.bytecode.club.bytecodeviewer.resources.importing.impl.APKResourceImporter.open(APKResourceImporter.java:47)
	at the.bytecode.club.bytecodeviewer.resources.importing.ImportResource.run(ImportResource.java:78)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.RuntimeException
	at com.googlecode.dex2jar.ir.ts.TypeTransformer$TypeAnalyze.mergeProviderType(Unknown Source)
	at com.googlecode.dex2jar.ir.ts.TypeTransformer$TypeAnalyze.mergeTypeToSubRef(Unknown Source)
	at com.googlecode.dex2jar.ir.ts.TypeTransformer$TypeAnalyze.copyTypes(Unknown Source)
	at com.googlecode.dex2jar.ir.ts.TypeTransformer$TypeAnalyze.fixTypes(Unknown Source)
	at com.googlecode.dex2jar.ir.ts.TypeTransformer$TypeAnalyze.analyze(Unknown Source)
	at com.googlecode.dex2jar.ir.ts.TypeTransformer.transform(Unknown Source)
	at com.googlecode.d2j.dex.Dex2jar$2.optimize(Unknown Source)
	at com.googlecode.d2j.dex.Dex2Asm.convertCode(Unknown Source)
	... 11 more

JimiSmith avatar Jul 02 '21 07:07 JimiSmith

It looks identical to the issue already reported on the dex2jar github repo: https://github.com/pxb1988/dex2jar/issues/462

JimiSmith avatar Jul 02 '21 07:07 JimiSmith

I am sure the error existed before as well, but wasn't shown in the terminal. Since I changed this behavior, this issue is properly shown to the user. I will need to further investigate this, though

ThexXTURBOXx avatar Jul 02 '21 10:07 ThexXTURBOXx

There are definitely classes present in the decompiled output of 2.9.22 that are missing in 2.10.12

I can reproduce this when decompiling the dex file that produces the error.

This is the decompiled output from 2.9.22 image This is from 2.10.12 image

In addition in 2.9.22 I can see the decompiled output of the method that causes dex2jar to fail in 2.10.12.

I can reproduce the exact error using dex2jar manually, so I guess it's a regression created in a new version of dex2jar

JimiSmith avatar Jul 02 '21 10:07 JimiSmith

@Konloch We should see whether we can fix the issue ourselves or if we should just downgrade dex2jar. I am, sadly, not very confident that dex2jar won't get neither a major nor a bugfix update soon. Maybe, we should just include the dex2jar version that was bundled with 2.9.22 back then?

ThexXTURBOXx avatar Jul 02 '21 12:07 ThexXTURBOXx

Addendum: Maybe we should also take a look at the forks of geilige, DexPatcher, and some more: https://techgaun.github.io/active-forks/index.html#https://github.com/pxb1988/dex2jar

As far as I can remember, I built the version of Dex2Jar currently employed myself. It includes some PRs already (the bitwise negate operator fix, the Gradle PR and some others). Maybe we can find some magic work in some other forks

ThexXTURBOXx avatar Jul 02 '21 12:07 ThexXTURBOXx

I tested with the latest dex2jar build from https://github.com/DexPatcher/dex2jar and it seems to work correctly with my APK

JimiSmith avatar Jul 05 '21 07:07 JimiSmith

I will investigate this issue when I am home again. Did you share your APK somewhere? Do you have the appropriate legal rights to upload it here or can you send us a link to the APK in question?

I didn't have this issue with any of my APKs yet. That's why I am asking for a non-working APK :)

ThexXTURBOXx avatar Jul 06 '21 15:07 ThexXTURBOXx

I can't share the APK unfortunately. It's from an unreleased product my company is working on. If I have some time I'll see if I can reproduce it with a sample project that I can share

JimiSmith avatar Jul 06 '21 15:07 JimiSmith

Could you please try if this snapshot fixes your issue? https://github.com/Konloch/bytecode-viewer/suites/3473954380/artifacts/82608578

ThexXTURBOXx avatar Aug 09 '21 21:08 ThexXTURBOXx