Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dex2jar: use classes as android library? #615

Open
mhous33 opened this issue Apr 15, 2024 · 4 comments
Open

dex2jar: use classes as android library? #615

mhous33 opened this issue Apr 15, 2024 · 4 comments

Comments

@mhous33
Copy link

mhous33 commented Apr 15, 2024

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?

@ThexXTURBOXx
Copy link
Collaborator

Three possibilities:

  1. 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
  2. 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
  3. 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.

@mhous33
Copy link
Author

mhous33 commented Apr 15, 2024

Thanks for the reply!
I just tried again, using your latest release. Here are my steps:

  1. d2j-dex2jar.sh *.apk
  2. extract *dex2jar.jar
  3. delete all contents except org/koin directory
  4. jar -cf koin.jar *
  5. copy koin.jar to android studio project libs directory
  6. 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"))
  7. 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,,boolean,,int,)
location: class ComponentCallbacksExtKt

Let me know if I can provide any more details!

@ThexXTURBOXx
Copy link
Collaborator

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).

@mhous33
Copy link
Author

mhous33 commented Apr 16, 2024

Thanks for the info! I will have to try a different approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants