testwhat / SmaliEx

A wrapper to get de-optimized dex from odex/oat/vdex.
529 stars 142 forks source link

Android 7.0 DP5 cannot work well. #36

Closed imknown closed 8 years ago

imknown commented 8 years ago

I have seen the issue #19 , but it still throws Exception:

D:\TryDeodex>java -jar oat2dex.jar boot boot.oat
08-11 20:32:10:750 Invalid dex version dex
08-11 20:32:10:771 Output raw dex: D:\TryDeodex\odex\core-oj.dex
08-11 20:32:10:774 Invalid dex version dex
Exception in thread "main" org.jf.dexlib2.dexbacked.DexBackedDexFile$NotADexFile: Invalid magic value: 64 65 78 0a 30 33 37 00
        at org.jf.dexlib2.dexbacked.DexBackedDexFile.verifyMagicAndByteOrder(DexBackedDexFile.java:151)
        at org.jf.dexlib2.dexbacked.DexBackedDexFile.<init>(DexBackedDexFile.java:70)
        at org.jf.dexlib2.dexbacked.DexBackedDexFile.<init>(DexBackedDexFile.java:96)
        at org.rh.smaliex.DexUtil.loadSingleDex(DexUtil.java:91)
        at org.rh.smaliex.DexUtil.loadMultiDex(DexUtil.java:108)
        at org.rh.smaliex.DexUtil.getClassPath(DexUtil.java:163)
        at org.rh.smaliex.DexUtil$ODexRewriterModule.<init>(DexUtil.java:406)
        at org.rh.smaliex.DexUtil$ODexRewriterModule.<init>(DexUtil.java:410)
        at org.rh.smaliex.DexUtil.getODexRewriter(DexUtil.java:348)
        at org.rh.smaliex.OatUtil.convertToDex(OatUtil.java:300)
        at org.rh.smaliex.OatUtil.convertDexFromBootOat(OatUtil.java:246)
        at org.rh.smaliex.OatUtil.bootOat2Dex(OatUtil.java:134)
        at org.rh.smaliex.Main.mainImpl(Main.java:113)
        at org.rh.smaliex.Main.main(Main.java:54)
kasptom commented 8 years ago

"The commit 227f79c should be able to extract dex for android N. (Tested with emulator, only an error when deodex apache-xml.dex) I did not upload last snapshot build because N is not formal release yet. To have a try, just pull the latest code and build with command in the readme."

So: 1) git clone https://github.com/testwhat/SmaliEx.git

2) go to SmaliEx (look at README.md) and type: gradlew -b smaliex/build.gradle dist

3) You should find the oat2dex.jar in smaliex-bin/ directory

imknown commented 8 years ago

Thank you. I tried it.

java -jar oat2dex.jar smali xxxx.odex

Above cmd worked, but the below still goes wrong.

java -jar oat2dex.jar boot boot.oat

Exception:

08-12 17:07:00:917 Output raw dex: D:\TryDeodex\odex\core-oj.dex
08-12 17:07:01:011 Art version=79 (boot.oat)
08-12 17:07:01:015 De-optimizing /system/framework/core-oj.jar
#addred# public abstract java.lang.String toString()
#addred# public abstract java.lang.String toString()
...
#addred# public abstract java.lang.String toString()
#addred# public abstract java.lang.String toString()
#addred# public default java.util.Spliterator spliterator()
#addred# public default java.util.Spliterator spliterator()
#addred# public abstract java.lang.String toString()
#addred# public abstract java.lang.String toString()
...
#addred# public abstract java.lang.String toString()
#addred# public abstract java.lang.String toString()
08-12 17:07:02:662 Failed to re-construct dex org.jf.dexlib2.analysis.UnresolvedClassException: Could not resolve class Ldalvik/system/BaseDexClassLoader;
08-12 17:07:02:662 convertToDex: skip /system/framework/core-oj.jar
kasptom commented 8 years ago

Try to find on Your device / emulator folder like x86 or x86_64 than pull from your device the whole directory and run something like:

java -jar oat2dex.jar boot x86

If you are using device with arm the directory You are searching for would be arm/ instead of the two above. Directory location, e.g. /system/framework/x86

EDIT: As @testwhat wrote in https://github.com/testwhat/SmaliEx/commit/227f79ca11a29979f2cb34d69aa0be0ed17e857f "Android N separates boot oat files ". I tried to run the above and it "worked"...

kasptom commented 8 years ago

... here is my question to @testwhat, if a may... after running the command above I've got two directories:

x86_64-odex/ contains a dex file wich I am trying to convert to .jar... I've tried to do it with [... x86_64-odex]$ sh path/to/dex2jar-2.0/d2j-dex2jar.sh one_of_the_dex_file.dex but I get:

dex2jar one_of_the_dex_filedex -> ./one_of_the_dex_file.jar
com.googlecode.d2j.DexException: not support version.
        at com.googlecode.d2j.reader.DexFileReader.<init>(DexFileReader.java:151)
        at com.googlecode.d2j.reader.DexFileReader.<init>(DexFileReader.java:211)
        at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java:104)
        at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:288)
        at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:32)

any suggestions would be appreciated :)

Edit: Android API: 24

imknown commented 8 years ago

Very nice! Worked~ I get the dex format now~


These cmd helped me as you said:

java -jar oat2dex.jar boot system\framework\arm64
java -jar oat2dex.jar xxxx.odex system\framework\arm64-odex

Thank you alot~ :laughing: Btw, my phone is arm64-v8a.

Update:

CLI throws several exceptions, but itself still succeeds.