dex2jar
dex2jar copied to clipboard
dex2jar: use classes as android library?
I am trying to rebuild an apk in android studio that I decompiled with jadx. The apk depends on a deprecated version of the koin dependency injection framework. I have tried adding current koin dependencies to my build.gradle, but it does not resolve the dependencies. I have also tried adding the koin java source to the project, but the source does not compile. So I had the idea to use dex2jar to get the koin class files and build a standalone jar to add to my project. I think I have done this correctly, as the koin import statements are satisified, however, when I try to build the apk, android studio throws the error: "error: cannot find symbol" referring to one of the classes in the koin jar library. Any ideas as to why this is not working?
Three possibilities:
- dex2jar is not perfect - in fact no dalvik converter is perfect and they cannot be perfect either. It could just be one of the cases where dex2jar just cannot deal with the given dalvik bytecode
- The class it is referring to could be a nested class. There are a few well-known problems within dex2jar when it tries to deal with those
- Try to use my fork, which has a few more fixes (and also an experimental
-cf
option, which might give better/more accurate output)
Overall, you have not provided enough data to figure this issue out yet - no mention of the specific symbol name or anything.
Thanks for the reply! I just tried again, using your latest release. Here are my steps:
- d2j-dex2jar.sh *.apk
- extract *dex2jar.jar
- delete all contents except org/koin directory
- jar -cf koin.jar *
- copy koin.jar to android studio project libs directory
- In android studio: project structure > dependencies > Add Dependency > JAR/AAR Dependency libs/koin.jar implementation This produces the following in my build.gradle dependencies list: implementation(files("libs/koin.jar"))
- Run
app
This produces the following error:
/home/mhous33/AndroidStudioProjects/RetroRazr/app/src/main/java/com/motorola/retrorazr/RazrApplication.java:24: error: cannot find symbol
ComponentCallbacksExtKt.startKoin$default(this, this, CollectionsKt.listOf((Object[]) new Function1[]{KoinModulesKt.getButtonsModule(), KoinModulesKt.getSoftKeysModule(), KoinModulesKt.getDialNumberModule(), KoinModulesKt.getStatusBarModule(), KoinModulesKt.getStateModule()}), null, false, null, 28, null);
^
symbol: method startKoin$default(RazrApplication,RazrApplication,List<Object>,
Let me know if I can provide any more details!
ComponentCallbacksExtKt.startKoin$default
is exactly something that dex2jar probably tries to convert to Java, but is not able to:
It tries to replace the $
by a .
, but this fails as default
by its own is a reserved keyword in Java. Hence, it is not possible to properly convert this function.
There are a few workarounds, but none has been implemented yet. Your best bet currently is to just rename this function on your own (it should exist - just with a slightly different, but very similar name).
Thanks for the info! I will have to try a different approach.