我面临一个我无法弄清楚的问题。 当我在第一个活动屏幕上回溯到主窗口时,会出现此ANR。 按下它后,然后我尝试返回应用程序,出现一个白色屏幕,然后是黑屏。 在一两分钟内,会出现ANR消息弹出窗口。
这是我的gradle play-services相关
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
我的启动器活动应该在用户首次进入应用时出现:
public class FirstActivity extends AppCompatActivity {
public void onCreate() {
if (userDataAccess.getUserProfile() != null) {
startDashBoardActivity();
finish();
} else if (!preferences.isFirstAccess().get()) {
startLoginActivity();
}
}
}
我的SignIn活动:
@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);
}
}
答案 0 :(得分:6)
这似乎是游戏服务9 +的一个问题。
我的第一个解决方法是回滚游戏服务到8.4.0,一切都恢复正常。
我一直在寻找解决方案,因为上面的内容并不能让我满意,而且
我发现问题是“通用游戏服务”。具体来说,我不明白为什么它适用于8.4.0而不是9 +。
我的解决方案是删除以下行
compile "com.google.android.gms:play-services:9.0.2"
并保持具体(这是最好的方式,无论问题是什么)
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"
它有效!
我真的想知道为什么错误是ANR。