Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ANR with TagManagerService

I'm facing an issue that I can't figure out. This ANR appear when I backPress on my first activity screen to go to the home window. After I press it, and then I try to go back to the application, a white screen appears, and after that, a black screen. In one or two minutes, the ANR message pop-up appears.

That`s my gradle play-services related

def googlePlayServicesVersion = '9.0.2'


compile "com.google.android.gms:play-services:$googlePlayServicesVersion"
compile "com.google.android.gms:play-services-analytics:$googlePlayServicesVersion"
compile "com.google.android.gms:play-services-auth:$googlePlayServicesVersion"
compile "com.google.android.gms:play-services-vision:$googlePlayServicesVersion"

Starting window AppWindowToken{44f94e90 token=Token{42a85dc8 ActivityRecord{430f4b70 u0 com.ioa***.****/com.******.****.activity.SignUpInTabActivity_ t84}}} timed out

ANR in com.ioa***.****
      PID: 24075
      Reason: Executing service com.ioacom.ioa***.****/com.google.android.gms.tagmanager.TagManagerService
      Load: 4.49 / 4.91 / 5.12
      CPU usage from 5972ms to 0ms ago:
      1.3% 372/adbd: 0.1% user + 1.1% kernel / faults: 406 minor
      1.1% 953/system_server: 0.6% user + 0.5% kernel / faults: 6 minor
      0.1% 1//init: 0% user + 0.1% kernel / faults: 52 minor
      0.3% 1053/com.android.systemui: 0.3% user + 0% kernel / faults: 2 minor
      0.3% 18921/kworker/0:2: 0% user + 0.3% kernel
      0.1% 3/ksoftirqd/0: 0% user + 0.1% kernel
      0.1% 8/rcu_preempt: 0% user + 0.1% kernel
      0.1% 144/mmcqd/0: 0% user + 0.1% kernel
      0% 204/servicemanager: 0% user + 0% kernel
      0% 224/mediaserver: 0% user + 0% kernel
      0% 1097/wpa_supplicant: 0% user + 0% kernel
      0.1% 1749/mpdecision: 0.1% user + 0% kernel
      0% 17052/kworker/u8:7: 0% user + 0% kernel
      0% 20159/kworker/0:3: 0% user + 0% kernel
      0% 24075/com.ioa***.******: 0% user + 0% kernel
      9.3% TOTAL: 2.8% user + 6.2% kernel + 0.1% iowait
      CPU usage from 2824ms to 3341ms later:
      3.8% 953/system_server: 0% user + 3.8% kernel / faults: 1 minor
      3.8% 967/ActivityManager: 0% user + 3.8% kernel
      9% TOTAL: 0% user + 0% kernel + 9% iowait

My Launcher Activity that should appear just first time user enters app :

public class FirstActivity extends AppCompatActivity {

    public void onCreate() {
        if (userDataAccess.getUserProfile() != null) {
            startDashBoardActivity();
            finish();
        } else if (!preferences.isFirstAccess().get()) {
            startLoginActivity();
        }
    }

} 

My SignIn activity :

@EActivity(R.layout.activity_with_tabs_layout)
public class SignUpInTabActivity extends AppCompatActivity {

    @ViewById(R.id.toolbar)
    Toolbar toolbar;

    @ViewById(R.id.tabs)
    TabLayout tabLayout;

    @ViewById(R.id.viewpager)
    ViewPager viewPager;

    private LoginFragment loginFragment;

    @AfterViews
    public void init(){
        setSupportActionBar(toolbar);
        ViewCompat.setElevation(tabLayout, 4);
        if(getSupportActionBar() != null) {
            toolbar.setSubtitleTextColor(ContextCompat.getColor(this, android.R.color.white));
            toolbar.setTitleTextColor(ContextCompat.getColor(this, android.R.color.white));
            toolbar.setTitle(R.string.*****);
            toolbar.setSubtitle(R.string.flavor);
        }
        setupViewPager();
    }

    @UiThread
    public void setupViewPager() {
        loginFragment = LoginFragment_.builder().build();
        ViewPagerTabsAdapter adapter = new ViewPagerTabsAdapter(getSupportFragmentManager());
        adapter.addFragment(loginFragment, getString(R.string.login).toUpperCase());
        adapter.addFragment(SignUpFragment_.builder().build(), getString(R.string.register_user).toUpperCase());
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        loginFragment.onActivityResult(requestCode,resultCode,data);
    }

}
like image 839
Lucas Ferraz Avatar asked Jun 16 '16 12:06

Lucas Ferraz


1 Answers

It seems to be a problem with play-services 9+.

My first workaround was rollback play-services to 8.4.0, and everything work again.

I keep looking for a solution, because the above does not satisfy me, and

I found that the problem was the 'generic play services' with the specific, I don`t understand why it works on 8.4.0 and not in 9+.

My solution is remove the below line

compile "com.google.android.gms:play-services:9.0.2"

and keep just the specific (this is the best way, regardless of the problem in question)

compile "com.google.android.gms:play-services-analytics:9.0.2"
compile "com.google.android.gms:play-services-auth:9.0.2"
compile "com.google.android.gms:play-services-vision:9.0.2" 

And it Works!

I Really want to know why the error was a ANR.

like image 77
Lucas Ferraz Avatar answered Oct 20 '22 16:10

Lucas Ferraz