java.lang.IllegalArgumentException:尝试删除从未添加的 OnFrameMetricsAvailableListener
Posted
技术标签:
【中文标题】java.lang.IllegalArgumentException:尝试删除从未添加的 OnFrameMetricsAvailableListener【英文标题】:java.lang.IllegalArgumentException: attempt to remove OnFrameMetricsAvailableListener that was never added 【发布时间】:2019-03-27 11:49:10 【问题描述】:该应用在 android 8 上崩溃。
当我尝试从 mainActivity 打开任何 Activity 时,然后按回主 Activity 并尝试打开任何其他 Activity 导致应用程序崩溃
它说应用程序无法停止主要活动!
这是日志
2018-10-23 12:19:33.963 20358-20358/global.medicount.healthpass.dev E/AndroidRuntime: FATAL EXCEPTION: main
Process: global.medicount.healthpass.dev, PID: 20358
java.lang.RuntimeException: Unable to stop activity global.medicount.healthpass.dev/global.medicount.healthpass.ui.main.MainActivity: java.lang.IllegalArgumentException: attempt to remove OnFrameMetricsAvailableListener that was never added
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4038)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4087)
at android.app.ActivityThread.-wrap24(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1625)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
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:6252)
at android.view.Window.removeOnFrameMetricsAvailableListener(Window.java:889)
at android.support.v4.app.FrameMetricsAggregator$FrameMetricsApi24Impl.remove(FrameMetricsAggregator.java:436)
at android.support.v4.app.FrameMetricsAggregator.remove(FrameMetricsAggregator.java:246)
at com.google.android.gms.internal.firebase-perf.zze.onActivityStopped(Unknown Source:60)
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:636)
at android.support.v7.app.AppCompatActivity.onStop(AppCompatActivity.java:184)
at global.medicount.healthpass.ui.base.BaseActivity.onStop(BaseActivity.java:388)
at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1376)
at android.app.Activity.performStop(Activity.java:7205)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4035)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4087)
at android.app.ActivityThread.-wrap24(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1625)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
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:
dependencies
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.google.firebase:firebase-plugins:1.1.5'
classpath 'io.fabric.tools:gradle:1.25.4'
依赖关系:
implementation "com.google.firebase:firebase-core:16.0.4"
implementation "com.google.firebase:firebase-messaging:17.3.4"
implementation 'com.google.firebase:firebase-perf:16.1.2'
我已经在旧的 android 版本 (6) 上测试了这个问题,但问题没有发生。并且该应用程序运行良好。 我已经看到了一些降级 firebase-pref 的解决方案,但这并没有解决我的问题。我不知道我必须做什么。
【问题讨论】:
您是否尝试同时降级 google 服务和 firebase-pref ? @OussemaAroua,我已经降级为以下 'com.android.tools.build:gradle:3.1.2' 'com.google.gms:google-services:3.2.1' ' com.google.firebase:firebase-perf:15.2.0' 仍然有问题 请添加代码并指出出现此错误的行。 【参考方案1】:尝试从AndroidManifest.xml
中的application
标记下删除android:hardwareAccelerated="false"
。
这解决了我的问题,而无需降级任何库。
【讨论】:
【参考方案2】:这是解决我的问题以使我的项目成功编译和运行的解决方案。
gradle 项目
buildscript
repositories
google()
jcenter()
maven url 'https://maven.fabric.io/public'
dependencies
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.google.firebase:firebase-plugins:1.1.5'
classpath 'io.fabric.tools:gradle:1.25.4'
allprojects
repositories
google()
jcenter()
maven
url "https://maven.google.com" // Google's Maven repository
task clean(type: Delete)
delete rootProject.buildDir
ext
// Sdk and tools
minSdkVersion = 19
targetSdkVersion = 28
compileSdkVersion = 28
buildToolsVersion = '28.0.0'
versionCode = 18
versionName = '3.6.0'
// App dependencies
supportLibraryVersion = '28.0.0'
....
这里是 AppGradle 依赖项
implementation "com.google.firebase:firebase-core:16.0.4"
implementation "com.google.firebase:firebase-messaging:17.3.4"
implementation "com.google.firebase:firebase-perf:16.1.2"
另外,我在Async任务中遇到了一个问题,所以它说Async可以执行一次,所以解决方法是
uploadUserIdProofTask.cancel(true);
uploadUserIdProofTask = new UploadUserIdProof();
uploadUserIdProofTask.execute(objects);
这些行帮助了我,我不知道这与日志之间有什么关系,但它对我有用。
【讨论】:
以上是关于java.lang.IllegalArgumentException:尝试删除从未添加的 OnFrameMetricsAvailableListener的主要内容,如果未能解决你的问题,请参考以下文章