Skip to content

ANRWatchDog ANRListener not working in debug mode  #4

Description

@Adeel984

I'm trying to use this repo to get ANR errors and log it into Crashlytics but unfortunately while debugging niether call back for SetANRListener is working nor SetANRInterceptor.
Here is how i'm using it.

in my MainActivity

new ANRWatchDog(1000).SetANRListener(new MyANRListener())
                .SetIgnoreDebugger(true)
                .SetANRInterceptor(new MyANRInterceptor())
               // .SetReportMainThreadOnly()
                .Start();

Classes for listeners

public class MyANRListener : ANRWatchDog.IANRListener
	{
		public void OnAppNotResponding(ANRError error)
		{
            //Handle the ANR error. log it to Crashlytics:
            try
            {
                Crashlytics.Crashlytics.LogException(error);
            } catch(Exception ex)
            {

            }
		}
    }
public class MyANRInterceptor : IANRInterceptor
    {
        string TAG = "ANR: ";
        public long Intercept(long duration)
        {
            long ret = 5000 - duration;
            if (ret > 0)
            {
                Log.Warn(TAG, $"Intercepted ANR that is too short ({duration} ms), postponing for {ret} ms");
            }
            return ret;
        }
        public MyANRInterceptor()
        {
        }
    }

I'm trying with Thread.Sleep(10000); i'm getting ANR but none of your listener are getting hit while debugging.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions