18

Android 2.2. I need to debug my signed APK on my Nexus S. How can this be done using Eclipse?

I start the app on my phone and then...?

l33t
  • 18,692
  • 16
  • 103
  • 180

4 Answers4

26

Set the debuggable=true in the manifest, export, install and sign the the app. Connect the device via USB, enable USB debugging. Then open the DDMS perspective, select the device and attach to your app's process (you will see the package name listed). If you have a rooted device, you can connect to any process if adb is running as root.

Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84
  • Thanks. Unfortunately, afaik, `debuggable` must be set to false when using in-app billing (which is why I need to debug a signed app in the first place). – l33t Apr 09 '12 at 13:57
  • 1
    Why *must*? Doesn't the Android Market/Paly console let you upload an APK with debuggable set to true? – Nikolay Elenkov Apr 09 '12 at 14:00
  • Hm, I read that somewhere. I'll test it and see if it works. I'll get back to you :) – l33t Apr 09 '12 at 14:04
  • @NikolayElenkov - I Managed to activate the debugging and see the bug icon next to the app. The code even stops at breakpoints. The problem is that I don't see any code, but rather a new blank editor is shown :( – AlikElzin-kilaka Dec 16 '13 at 13:24
  • I take that back. I restarted Eclipse and closed all other projects and it worked - the breakpoint stopped and showed me the code. – AlikElzin-kilaka Dec 16 '13 at 17:08
  • @user3093402 in AndroidManifext.xml in – Maciek Czarnik Jun 12 '14 at 14:53
  • Ok, but still unable to send such build to Google Play "You uploaded a debuggable APK. For security reasons you need to disable debugging before it can be published in Google Play." – Maciek Czarnik Jun 12 '14 at 14:55
  • For my situation, this part did the trick *"Then open the DDMS perspective, select the device and attach to your app's process (you will see the package name listed)"* .. thanks! – Gene Bo Jan 26 '16 at 19:59
4

When device connect to your eclipse running mechine , set debuggable=true in manifest file and enable debug mode in android phone it can view current running log using logcat, otherwise

You can debug your running application using adb tools from the command line

adb logcat - View device log

will display the current logcat (debug messages)

adb logcat [ <filter-spec> ]

using you can filter only your given debug messages

for configure debug tool view http://developer.android.com/guide/developing/tools/adb.html

UdayaLakmal
  • 4,035
  • 4
  • 29
  • 40
3

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.

sandalone
  • 41,141
  • 63
  • 222
  • 338
-1

You have two ways ..

  1. You can use Log.v or log.d or Log.i (Logging) in your code and get all those logs in logcat view in eclipse while your application runs on your device.
  2. You can run (while debugging , pressing that insect icon on eclipse ) the application from eclipse on device, By putting breakpoints in your code you can debug your application.
Relsell
  • 771
  • 6
  • 18
  • Logging is a the last resort. The insect works only for apps signed with the debug key. The main issue here is that my app needs to be signed. – l33t Apr 09 '12 at 14:00
  • umm.. as far as I know... you can build a custom key store ... and then add that to your eclipse ... under windows->Preferences.... then during application run .. your apk will be signed with this custom key automatically . – Relsell Apr 09 '12 at 14:22