DexPatcher / multidexlib2

Multi-dex extensions for dexlib2
https://dexpatcher.github.io/
GNU General Public License v3.0
68 stars 34 forks source link

ClassNotFoundException #3

Closed SamHoque closed 5 years ago

SamHoque commented 6 years ago

java.lang.RuntimeException: Unable to instantiate application com.lynx.Application: java.lang.ClassNotFoundException: Didn't find class "com.lynx.Application:" on path: DexPathList[[zip

Looks like the library did not detect this as a start up class and put it in a secondary dex file.

SamHoque commented 6 years ago

Edit: Just confirmed the class is in the main dex file but still getting that crash error.

Lanchon commented 6 years ago

hi,

thanks for using multidexlib2.

only dalvikvm (up to android 4.4.x) requires bootstrap classes to be in main dex. ART (from android 5 and on) just loads all dex files at startup, so content of main dex is irrelevant.

your issue is main dex issue only if using android version prior to 5, which i guess is unlikely. so it probably is something else.

Looks like the library did not detect this as a start up class and put it in a secondary dex file.

multidexlib2 does not attempt to detect anything of the sort. only if you want android 4 and earlier compatibility, then it is your job to define the content of the main dex. you do this:

SamHoque commented 6 years ago

I have confirmed the class is in the main dex but its still causing ClassNotFound error i cannot think of anything else why it would do this.

Lanchon commented 6 years ago

you are not posting any details. you havent even said which android version you are running on.

SamHoque commented 6 years ago

I have tested it on memu android emulator android version (4.4.4)

here is the code I used to do the multidex

try {
    DexFile dexfile = MultiDexIO.readDexFile(true,
        new File("C:\\Users\\vrb_g\\Desktop\\Apks-To-Decompile\\kik.apk"),
        new BasicDexFileNamer(),
        null,
        null
    );
    DexRewriter rewriter = new DexRewriter(new RewriterModule() {
        @Nonnull
        public Rewriter < Method > getMethodRewriter(@Nonnull Rewriters rewriters) {
            return value - > value;
        }
    });
    DexFile rewrittenDexFile = rewriter.rewriteDexFile(dexfile);
    String outFile = "C:\\Users\\vrb_g\\Desktop\\Apks-To-Decompile\\";
    MultiDexIO.writeDexFile(true, 0, new File(outFile), new BasicDexFileNamer(), rewrittenDexFile, DexIO.DEFAULT_MAX_DEX_POOL_SIZE, null);
} catch (IOException e) {
    e.printStackTrace();
}

here is the link to the apk I tried it on https://www.apkmirror.com/apk/kik-interactive/kik/kik-10-17-2-10560-release/

Lanchon commented 6 years ago

android 4 is completely obsolete. its not maintained and has security holes. i recommend you use ART which happens not to have multidex ordering issues.

if you insist on using multidex on dalvikvm you are on your own. dalvik does not understand multi and apps need their own multi emulation code and class loader in the main dex. you will have to research how to make it work and then use multidexlib2's main dex support to write the dex files. that entails knowing the set of classes that are required to exist in the main dex.

that said, you could try read then write the mdex without any rewriting. if it works on android 5 but not 4.4, it probably is a main dex content issue. if it doesnt work on 5, it is probably anti-tampering code in the app.

SamHoque commented 6 years ago

I have tested it on android 7.1 and it does not work on it as well, am using the dexlib library on intelliJ and no the app does not have anti tampering code I was able to mod it just fine it breaks when I use dexlib on it

Lanchon commented 6 years ago

well if you cannot share the complete case that is failing then i am afraid i cannot help you more with generalities.

SamHoque commented 6 years ago

Well You can try to redex the files on https://www.apkmirror.com/apk/kik-interactive/kik/kik-10-17-2-10560-release/ and check for your self it does not work.

Lanchon commented 5 years ago

have you taken this upstream to the smali project?