IllegalArgumentException:尝试删除从未添加的OnFrameMetricsAvailableListener

时间:2019-03-26 07:54:02

标签: android firebase-performance

我们在应用中使用firebase-perf插件,但是在测试时,我们得到了此错误的多个实例 IllegalArgumentException: attempt to remove OnFrameMetricsAvailableListener that was never added

请找到下面给出的日志。

 Process: packageName, PID: 27378
    java.lang.RuntimeException: Unable to stop activity {packageName.Activity}: java.lang.IllegalArgumentException: attempt to remove OnFrameMetricsAvailableListener that was never added
        at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4369)
        at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4425)
        at android.app.ActivityThread.-wrap5(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:172)
        at android.app.ActivityThread.main(ActivityThread.java:6590)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.IllegalArgumentException: attempt to remove OnFrameMetricsAvailableListener that was never added
        at android.view.View.removeFrameMetricsListener(View.java:6244)
        at android.view.Window.removeOnFrameMetricsAvailableListener(Window.java:889)
        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:33)
        at android.app.Application.dispatchActivityStopped(Application.java:234)
        at android.app.Activity.onStop(Activity.java:1862)
        at android.support.v4.app.FragmentActivity.onStop(FragmentActivity.java:613)
        at android.support.v7.app.AppCompatActivity.onStop(AppCompatActivity.java:183)
        at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1376)
        at android.app.Activity.performStop(Activity.java:7205)
        at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4364)
        at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4425) 
        at android.app.ActivityThread.-wrap5(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:172) 
        at android.app.ActivityThread.main(ActivityThread.java:6590) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

遵循我们正在使用的gradle依赖项:

    classpath 'com.android.tools.build:gradle:3.3.1'
    classpath 'com.google.gms:google-services:4.0.2'
    classpath 'com.google.firebase:firebase-plugins:1.1.5'

    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-perf:16.1.0'

1 个答案:

答案 0 :(得分:0)

问题出在com.google.firebase:firebase-perf

移除     android:hardwareAccelerated="false" from AndroidManifest.xml

或者在您的活动中(从崩溃的消息中)执行以下操作:

@Override
protected void onStop() {
    try {
        super.onStop();
    } catch (Exception e) {
        Log.w(TAG, "onStop()", e);
        super.onStop();
    }
}