Android 8或更高版本使用Firebase Performance SDK在Android Oreo上崩溃的应用程序

书到用时方恨少,事非经过不知难。这篇文章主要讲述Android 8或更高版本使用Firebase Performance SDK在Android Oreo上崩溃的应用程序相关的知识,希望能为你提供帮助。
我添加了最新的Firebase Performance SDK,并且在android 8(Oreo)或更高版本的应用程序崩溃时出现了从未添加的错误消息OnFrameMetricsAvailableListener。
App Level build.gradle

dependencies { classpath 'com.android.tools.build:gradle:3.2.1' classpath 'com.google.gms:google-services:4.2.0' classpath 'com.google.firebase:firebase-plugins:1.1.5' }

【Android 8或更高版本使用Firebase Performance SDK在Android Oreo上崩溃的应用程序】app Module Level build.gradle
dependencies {other .............. ..............// Android support implementation 'com.android.support:support-v4:28.0.0' implementation 'com.android.support:appcompat-v7:28.0.0'// Android Gms Play Services implementation 'com.google.android.gms:play-services-gcm:16.0.0'// Firebase implementation 'com.google.firebase:firebase-perf:16.2.2' } apply plugin: 'com.google.gms.google-services' apply plugin: 'com.android.application' apply plugin: 'com.google.firebase.firebase-perf'

日志
Caused by: java.lang.IllegalArgumentException: attempt to remove OnFrameMetricsAvailableListener that was never added at android.view.View.removeFrameMetricsListener(View.java:6862) at android.view.Window.removeOnFrameMetricsAvailableListener(Window.java:890) at android.support.v4.app.FrameMetricsAggregator$FrameMetricsApi24Impl.remove(FrameMetricsAggregator.java:436) at android.support.v4.app.FrameMetricsAggregator.remove(FrameMetricsAggregator.java:246) at com.google.firebase.perf.internal.zza.onActivityStopped(Unknown Source:64) at android.app.Application.dispatchActivityStopped(Application.java:258) at android.app.Activity.onStop(Activity.java:1950) at android.support.v4.app.FragmentActivity.onStop(FragmentActivity.java:636) at android.support.v7.app.AppCompatActivity.onStop(AppCompatActivity.java:184) at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1382) at android.app.Activity.performStop(Activity.java:7526) at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4591) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4652) at android.app.ActivityThread.-wrap5(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1784) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:7002) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

答案您需要将perf的版本从16降级到15.这个问题可能会在即将推出的新版本中修复。
implementation 'com.google.firebase:firebase-perf:15.+'

或者你可以从android:hardwareAccelerated="true"删除AndroidMainfest.xml线

    推荐阅读