Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

attempt to remove OnFrameMetricsAvailableListener that was never added

Tags:

java

android

The app crashes everytime I exit the main activity, but only if I go into another activity before that. Meaning that, if I just go into the first screen and exit it befor entrying another activity, the app wont crash.

I'm getting the Crash on the "super.onStop();" line, in the main activity as a result of an error saying: "attempt to remove OnFrameMetricsAvailableListener that was never added".

The code worked fine last time, and the last thing I changed was the build.gradle and some classpath to: classpath 'com.android.tools.build:gradle:3.1.2' and classpath 'com.google.gms: google-services: 3.3.1'. nothing else..

(Also, the application crashes even if I'm not calling the onStop() method. and I wants to add that I'm not using FrameMetrics object in my project at all !!)

Thank very much to anyone who can help!

@Override
public void onStop() {
    super.onStop();

    StateManager mgr = new StateManager(this);
    if (mMap != null) {
        mgr.saveMapState(mMap);
    }
}

crash

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) 
like image 470
Neria Nabeth Avatar asked May 10 '18 20:05

Neria Nabeth


2 Answers

Removing android:hardwareAccelerated="false" from AndroidManifest.xml helped me

like image 177
Ivan Rudnev Avatar answered Nov 06 '22 17:11

Ivan Rudnev


For me the issue is because of com.google.firebase:firebase-perf:15.2.0, so I have resolved my issue by downgrading the version

implementation 'com.google.firebase:firebase-perf:15.+'
like image 35
Rajat Gupta Avatar answered Nov 06 '22 17:11

Rajat Gupta