How to debug apk signed for release?
Solution 1
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.
Solution 2
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.
Solution 3
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.
Solution 4
I tried with the following and it's worked:
release {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Solution 5
Add the following to your app build.gradle and select the specified release build variant and run
signingConfigs {
config {
keyAlias 'keyalias'
keyPassword 'keypwd'
storeFile file('<<KEYSTORE-PATH>>.keystore')
storePassword 'pwd'
}
}
buildTypes {
release {
debuggable true
signingConfig signingConfigs.config
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
![Adil Hussain](https://i.stack.imgur.com/dTt5I.jpg?s=256&g=1)
Adil Hussain
Software Engineer with a focus on building Applications and SDKs for Mobile (Android, iOS).
Updated on March 18, 2021Comments
-
Adil Hussain over 3 years
I have an apk which I've signed and uploaded to Android Market, and installed on my phone. I would like to debug this release apk (by means of Eclipse) whilst it is running on my phone. I have done this before (and remember it being with one of the Android development tools; perhaps Dalvik Debug Monitor) but unfortunately cannot remember how to do it and have been unable to find any articles online. Does anyone know how this can be done?
Note: I have set
android:debuggable="true"
in the manifest and have enabled USB Debugging on my phone. -
Adil Hussain over 12 yearsI get up to step 8 but for some reason my app's package name doesn't show when I'm running the signed/release apk. (Strangely it does show when I run the app (debug apk) on my phone straight from Eclipse.) Confused...
-
Adil Hussain over 12 yearsGot it! I had put the
android:debuggable="true"
attribute in themanifest
tag instead of theapplication
tag within manifest!! My bad :( Thanks Sam_D ever so much for your guidance. Wouldn't have done it without you, or at best would have taken a heck of a long time! -
m02ph3u5 over 8 yearsNote that as of gradle 1.0 it's minifyEnabled instead of runProguard - see tools.android.com/tech-docs/new-build-system/migrating-to-1-0-0
-
sandalone about 8 years@jaibatrik it has to be your apk and you have to attach the debugger from the sources. if you are doing both and it still does not work, share more info and I may try to help
-
J D about 7 yearsI got "[Fatal Error] :7:203: The prefix "tools" for attribute "tools:ignore" associated with an element type "application" is not bound." Is tools:ignore="HardcodedDebugMode" a legit config here?
-
Adil Hussain almost 7 yearsThis answer has already been given in this thread by Manuel Lopera... three years ago! See here: stackoverflow.com/a/27181562/1071320
-
Shailendra Madda almost 7 years@AdilHussain But I tried that answer it's not worked for me. See there is a difference in my answer at ` minifyEnabled false` and it is
runProguard true
in his case. Please see the changes -
Adil Hussain almost 7 yearsNot a big deal but his answer does contain an update to this effect. Anyway. Not a big deal. Thanks for the answer.
-
hasnain_ahmad about 6 yearsWhen I add the debuggable keyword in build.gradle and want to publish in play store it shows this error
You uploaded a debuggable APK. For security reasons you need to disable debugging before it can be published in Google Play.
-
Antimonit over 5 yearsThis answer is way outdated. Instead of
androidManifest.xml
you should updatebuild.gradle
. See other answers. -
Shashank Saxena almost 5 years@hasnain_ahmad Were you able to find a solution for this?
-
Androidcoder over 4 yearsAs a note to this current answer, I myself would avoid sending a debuggable release to the Google Play store, and it may not let you as in hasnain_ahmad's case in previous outdated answer. Just doing it temporarily to test a release-downloaded-from-store issue, like inapp purchase code tracking, would be less risky. You could also try working with the beta track (I don't know if this may give the same error as hasnian got) or transferring the release build apk to your phone from your computer to avoid the security issues (dealing with the bundle is messier).
-
YoshiJaeger over 4 yearsI had to add
lintOptions { abortOnError false }
into my app/build.grade instead of usingtools:ignore
like so:android { lintOptions: { abortOnError false } }
-
Oliver D over 4 yearsi got
The prefix "tools" for attribute "tools:ignore" associated with an element type "application" is not bound.
!