How to debug apk signed for release?
Besides Manuel's way, you can still use the Manifest.
In Android Studio stable, you have to add the following 2 lines to application
in the AndroidManifest
file:
android:debuggable="true"
tools:ignore="HardcodedDebugMode"
The first one will enable debugging of signed APK, and the second one will prevent compile-time error.
After this, you can attach to the process via "Attach debugger to Android process" button.
I know this is old question, but future references. In Android Studio with Gradle:
buildTypes {
release {
debuggable true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
The line debuggable true
was the trick for me.
Before Gradle 1.0 it was runProguard
instead of minifyEnabled
. Look at here.
Be sure that android:debuggable="true"
is set in the application
tag of your manifest file, and then:
- Plug your phone into your computer and enable USB debugging on the phone
- Open eclipse and a workspace containing the code for your app
- In Eclipse, go to Window->Show View->Devices
- Look at the Devices view which should now be visible, you should see your device listed
- If your device isn't listed, you'll have to track down the ADB drivers for your phone before continuing
- If you want to step through code, set a breakpoint somewhere in your app
- Open the app on your phone
- In the Devices view, expand the entry for your phone if it isn't already expanded, and look for your app's package name.
- Click on the package name, and in the top right of the Devices view you should see a green bug along with a number of other small buttons. Click the green bug.
- You should now be attached/debugging your app.