Trace protocol stack and crashes not displayed in Android Studio

I am trying to debug an application on my device and am having problems with the debugger. I tried checking the logger to see if it would be written to Logcat as follows:

Log.d("MyActivity", "Testing logging..."); 

But nothing is displayed in Logcat with the filter app: com.myapp.debug . This happens when I just filter the string (using my application name), but the entry looks like this:

 01-08 13:45:07.468 29748-29748/? D/MyActivity﹕ Testing logging... 

Does this question mark mean that something in the application does not go through the debugger? This may relate to my second problem with the debugger:

I debug the crash and every time this happens, the phone simply displays a “not responding” message and then closes the current activity, disables the debugger, and the application continues to work with the previous action. No stack trace, no crash info, nothing. Is there something I need to set up in Android Studio to get this to work?

+6
source share
3 answers

I also have this problem, and I cannot find too good an answer for this. Instead, I did the job and caught the error with Thread.setDefaultUncaughtExceptionHandler () and ran it with Log.e ()

I used this class for this.

  public class ExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler { private final String LINE_SEPARATOR = "\n"; public static final String LOG_TAG = ExceptionHandler.class.getSimpleName(); @SuppressWarnings("deprecation") public void uncaughtException(Thread thread, Throwable exception) { StringWriter stackTrace = new StringWriter(); exception.printStackTrace(new PrintWriter(stackTrace)); StringBuilder errorReport = new StringBuilder(); errorReport.append(stackTrace.toString()); Log.e(LOG_TAG, errorReport.toString()); android.os.Process.killProcess(android.os.Process.myPid()); System.exit(10); } } 

Then in my work.

  @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /** * catch unexpected error */ Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler()); setContentView(R.layout.activity_main); //other codes } 

Hope this helps.

+12
source

I think this is an adb or filer problem. First remove all filters. Restart adb - type in the adb terminal kill-server && & &&& & adb start-server.

+4
source

Your Google analytics "ga_reportUncaughtExceptions" is probably set to true, turning it to false fixes the problem, and exceptions are printed on logcat. See the link below for more details.

Why doesn't logcat for Android show stack trace to exclude runtime?

+2
source

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


All Articles