I have an APK which is debuggable="true"
(according to the AndroidManifest), meaning I can debug it and this is what I want to do.
I used Android Studio: File -> Profile or Debug APK to load the apk (app.apk).
When I am trying to debug it (Shift+F9) it writes me:
Disassembled classes.dex file. To set up breakpoints for debugging, please attach Java source files
I used jadx to decompile the APK to java source code by running:
"c:\tmp\jadx-0.8.0\bin\jadx.bat" -d java_source app.apk
I now have inside the java_source directory two directories:
- resources
- sources
Inside the sources
folder I have the java files.
How can I attach them to the Android Studio project as it requests by the message?
Just open it as a new project?
Looks like the answer you want is available in the android docs (https://developer.android.com/studio/debug/apk-debugger#attach_java):
By default, Android Studio extracts Java code from your APK and saves them as .smali files. To debug the Java code using breakpoints, you need to point the IDE to the .java source files that correspond to the .smali files you want to debug.
To attach Java sources, proceed as follows:
Double click on a .smali file from the Project pane (use the Android view). After opening the file, the editor displays a warning banner asking you to select the Java sources, similar to what's shown in figure 1. Click Attach Java Sources from the banner at the top of the editor window. Navigate to the directory with the app’s Java source files and click Open.
In the Project window, the IDE replaces .smali files with their corresponding .java files—The IDE also includes inner classes automatically. You can now add breakpoints and debug your app as you normally would.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With