ANR Service execution com.example.app/com.google.android.gms.analytics.AnalyticsService

Sometimes after long periods of using my application, when I try to enable it, I get ANR. In the Google Play console, I get the following:

ANR Executing service my.site.app/com.google.android.gms.analytics.AnalyticsService 

Obviously, the problem is in the AnalyticsService . But I could not play ANR while my device was connected to my computer. And I do not see ANR in the analytic account.

This is my application class:

 public class BaseApp extends Application { public static GoogleAnalytics analytics; public static Tracker tracker; @Override public void onCreate() { analytics = GoogleAnalytics.getInstance(this); analytics.setLocalDispatchPeriod(1800); analytics.setDryRun(Constants.IS_DEBUG); GoogleAnalytics.getInstance(this).getLogger().setLogLevel(Logger.LogLevel.VERBOSE); tracker = analytics.newTracker(Constants.GOOGLE_ANALYTICS_TRACKER_ID); tracker.enableExceptionReporting(true); tracker.enableAdvertisingIdCollection(true); tracker.enableAutoActivityTracking(true); super.onCreate(); } } 

And then in my BaseActivity class:

 @Override public void onStart() { super.onStart(); sendScreenStat(); } protected String getScreenStatName() { return getTitle().toString(); } private void sendScreenStat() { BaseApp.tracker.setScreenName(getScreenStatName()); BaseApp.tracker.send(new HitBuilders.ScreenViewBuilder().build()); } 

What could be the reason?

+6
source share
1 answer

How activity lifecycle methods are launched in a user interface thread. make sure they are different from operations that may take a long time for background threads. in particular, sendScreenStat and creating a tracker to work in the background thread (AsyncTask or dedicated thread). More details here: http://blog.akquinet.de/2010/02/17/android-activities-the-predominance-of-the-ui-thread/

-2
source

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


All Articles