每次退出主要活动时应用程序都会崩溃,但前提是我在此之前进入另一项活动。 这意味着,如果我只是进入第一个屏幕并退出进入另一个活动,应用程序就不会崩溃。
我在主要活动中的“super.onStop();”行遭遇崩溃,因为出现错误:“尝试删除OnFrameMetricsAvailableListener从未添加“。
上次代码运行正常,我改变的最后一件事是build.gradle和一些类路径: classpath'com.android.tools.build:grad:3.1.2'和 classpath'com.google.gms:google-services:3.3.1'。没有别的..
(此外,即使我没有调用onStop()方法,应用程序也会崩溃。我想补充一点,我在项目中根本没有使用FrameMetrics对象!)
@Override
public void onStop() {
super.onStop();
StateManager mgr = new StateManager(this);
if (mMap != null) {
mgr.saveMapState(mMap);
}
}
崩溃
Process: com.example.nabeth.youandi, PID: 24034
java.lang.RuntimeException: Unable to stop activity {com.example.nabeth.youandi/com.example.nabeth.youandi.MapsActivity}: java.lang.IllegalArgumentException: attempt to remove OnFrameMetricsAvailableListener that was never added
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4209)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4265)
at android.app.ActivityThread.-wrap6(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1565)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
Caused by: java.lang.IllegalArgumentException: attempt to remove OnFrameMetricsAvailableListener that was never added**
at android.view.View.removeFrameMetricsListener(View.java:5573)
at android.view.Window.removeOnFrameMetricsAvailableListener(Window.java:865)
at android.support.v4.app.FrameMetricsAggregator$FrameMetricsApi24Impl.remove(FrameMetricsAggregator.java:432)
at android.support.v4.app.FrameMetricsAggregator.remove(FrameMetricsAggregator.java:245)
at com.google.android.gms.internal.firebase-perf.zzd.onActivityStopped(Unknown Source)
at android.app.Application.dispatchActivityStopped(Application.java:234)
at android.app.Activity.onStop(Activity.java:1815)
at android.support.v4.app.FragmentActivity.onStop(FragmentActivity.java:613)
at com.example.nabeth.youandi.MapsActivity.onStop(MapsActivity.java:2684)
at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1290)
at android.app.Activity.performStop(Activity.java:6932)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4204)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4265)
at android.app.ActivityThread.-wrap6(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1565)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
答案 0 :(得分:4)
对我来说问题是因为 com.google.firebase:firebase-perf:15.2.0 ,所以 我通过降级版本来解决我的问题
implementation 'com.google.firebase:firebase-perf:15.+'
答案 1 :(得分:4)
从AndroidManifest.xml中删除android:hardwareAccelerated="false"
对我有帮助
答案 2 :(得分:1)
firebase-perf的相同问题:16.1.2。以下解决方法对我有所帮助。 在您的活动中(根据崩溃的消息)执行以下操作:
@Override
protected void onStop() {
try {
super.onStop();
} catch (Exception e) {
Log.w(TAG, "onStop()", e);
super.onStop();
}
}