Can't debug APK: "To set up breakpoints for debugging, please attach Java source files"

E235 :

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?

Snail Cadet :

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=71517&siteId=1