How to set an exception checkpoint correctly in Android Studio?

I tried several months to make my debugger break my own code without success. Each uncaught exception is split into the ZygoteInit.run () method.

Here is a list of actions I have taken.

  • Added debug { debuggable true } to my build.gradle module file
  • Added manually by debuggable="true" to my AndroidManifest.xml file
  • Any exception checked in the breakpoints window
  • Added appropriate class filter templates to breakpoint Any exception
    • this causes the debugger to completely skip all uncaught exceptions

I am debugging by looking at the stack trace in Logcat, which shows my classes in the stack trace.

I saw this version on the current and previous lines in the stable and canary channels.

Is something missing here?

EDIT: just for clarification to people, the problem was that I had a "Caught exception" checkbox. . The problem is fixed in this field.

Here is the relevant part of my Gradle file, if it helps at all.

 android { compileSdkVersion 22 buildToolsVersion '22.0.0' defaultConfig { applicationId "com.--redacted--" minSdkVersion 15 targetSdkVersion 22 versionCode 30 versionName "0.0.30" multiDexEnabled true } packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/beans.xml' } buildTypes { debug { debuggable true } release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dexOptions { javaMaxHeapSize "4g" } } 

Here is a screenshot of my Breakpoints window.

Breakpoints window

+6
source share
2 answers

A few more things to provide:

  • Pause installation for everyone
  • Notifications of:
    • An exception is fixed if exceptions having a specific error handling should be caught
    • Unused exceptions if exceptions that are not handled must be caught
  • Set class filters to restrict your code, Android code and Java code

See more detailed instructions for more details: fooobar.com/questions/61731 / ...

Breakpoints dialog

This approach catches all the exceptions that arise (when "caught" and "not caught"). Thus, all internal exceptions arise. The class filter specification limits this by excluding some of these exceptions. For example, in the screenshot above, a ClassNotFoundException , which often occurs at startup, is ignored.

A minor drawback of this approach is that during application startup, a message may appear indicating "Unable to find source class for current stack frame". This is because the source code is not yet loaded. This will happen only once during startup and can be safely ignored. An alternative approach to avoid this (if there are no exceptions expected when the application starts) is to "Run" Run application (as opposed to launching "Debugging"), and then manually attach the application to the debugger using Run → Attach the debugger to the Android process ... or by clicking Attach on the toolbar.

+9
source

You need to attach a debugger to the running process.

You do not always need to restart the application to debug it.
To debug an application that you are already using:

  • Click "Attach Debugger to Android Process"
  • In the "Process Selection" window, select the device and application to which you want to connect the debugger to
  • To open the Debug tool window, click Debug

    To view and configure the breakpoints settings, click View Breakpoints on the left side of the Debug tool window. The Breakpoints window appears, and there you could configure them.

There are three main types of exceptions:

  • Checked exceptions: which should be handled by the code. These are preventable exceptional conditions that can be handled and restored.

  • Runtime exceptions: which code should not be processed. They represent unexpected exceptional conditions that can be handled, but not necessarily restored.

  • Errors: which should not be handled by code. These are serious unexpected exceptional conditions that shud have not tried to handle.

+1
source

Source: https://habr.com/ru/post/983997/


All Articles