Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android application lacking debug information in Android Studio

I'm trying to debug an application that I'm writing using Android Studio but I can't seem to get any useful debugging information out of Android Studio's "Debug" view. I'm launching my application with the bug-looking "Debug" icon but the "Debug" view doesn't have anything useful (no stack frames from my application, for example):

screenshot

Even if my application crashes I don't get any useful information. As I recall, the ADT plugin would automatically drop you on the line that caused the crash.

Do I need to do anything else to make my application "debuggable" in Android Studio? I've also tried forcing android:debuggable="true" in my AndroidManifest.xml but to no avail. Android Studio does seem to be attaching to the running process (the app shows the "attaching to debugger" message for a few seconds when it first launches).

like image 825
mgalgs Avatar asked Nov 25 '14 06:11

mgalgs


People also ask

How do I enable debug on APK?

To start debugging an APK, click Profile or debug APK from the Android Studio Welcome screen. Or, if you already have a project open, click File > Profile or Debug APK from the menu bar. In the next dialog window, select the APK you want to import into Android Studio and click OK.


1 Answers

There are some things to check:

  • If your app-debugger is working and stopping on normal breakpoints, maybe you have to set an exception-breakpoint:
    • Open Debugger
    • Press "View breakpoints"
    • Usually, there should be a breakpoint called "Any exception" with checkboxes on "Caught exception" and "Unchaught exception". If not, add an exception breakpoint yourself and specify the type(s) of exceptions you want the debugger to stop on (you can use wildcards in the exception-classnames, e.g. *Exception).
  • If your app-debugger is not working, check the following options:

    • Check if you have enabled USB-Debugging in the developer options of your device
    • Check if you have authorized the computer as a development machine in the developer options of the device (if unsure, clear the authorization-list from the developer options page and reconnect the device)
    • Check if your development machine has only one adb-server-process running in the background (if more, kill all of them with a process mananger and restart with "adb start-server")
    • Add "debuggable true" to your debug-buildType in build.gradle:

      buildTypes {
          debug {
              debuggable true
          }
          ...
      }
      
  • If your app-debugger is still not working, restart your computer and re-install adb-drivers for your device. Make sure there are no conflicting drivers active with more than one connected device (maybe connecting only one at a time).

Note: even if you got exception breakpoints working, they might not be useful at all, depending on the type of the crash. Most of the times, you will get the debugger stopping in the Zygote-exception handler where you don't get much useful information or stacktrace. In such cases, it is the easiest to just let the debugger resume or reproduce the crash without a debugger, and check the logcat-output for a stacktrace in the ERROR-loglevel of your app's logcat-output. Those stacktraces should have clickable line-infos thus enabling you to set a normal breakpoint on a relevant line of code in your app's source code to analyze the problem.

like image 97
arne.jans Avatar answered Oct 26 '22 04:10

arne.jans