Firebase Performance crashing in API 19 with Google Play Services 10.2.98

妖精的绣舞 提交于 2020-01-23 04:47:33

问题


This week I started testing the new Firebase Performance in my new app. Once I am using Firebase for other features like Auth and DB I already updated all packages to last 10.2.6 Firebase version and follow all pre req instructions.

minAPI is 19.

My problem is App is crashing only in API 19 with Google Play Services 10.2.98 in a real Galaxy Duos device running Android 4.4.1. When App starts it could not find firebase-perf in device.

It is only happening with this package and in other devices and higher versions everything is fine and I can see data in Firebase Performance Dashboard.

Tips ?

Stacktrace below

Regards,

Process: com.mobilecodelabs.fb.trampo, PID: 2727
java.lang.RuntimeException: Unable to get provider com.google.firebase.perf.provider.FirebasePerfProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.perf.provider.FirebasePerfProvider" on path: DexPathList[[zip file "/data/app/com.mobilecodelabs.fb.trampo-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.mobilecodelabs.fb.trampo-2, /vendor/lib, /system/lib]]
    at android.app.ActivityThread.installProvider(ActivityThread.java:4793)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325)
    at android.app.ActivityThread.access$1500(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5017)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.perf.provider.FirebasePerfProvider" on path: DexPathList[[zip file "/data/app/com.mobilecodelabs.fb.trampo-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.mobilecodelabs.fb.trampo-2, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
    at android.app.ActivityThread.installProvider(ActivityThread.java:4778)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385) 
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325) 
    at android.app.ActivityThread.access$1500(ActivityThread.java:135) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5017) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
    at dalvik.system.NativeStart.main(Native Method) 

回答1:


This is an old issue but posting an update for the benefit of others.

I have run into this issue my self with the exact same stack trace. My app is failing on API 19 and below, where as on 21+ it works without any issue. For me it turned out to be a MultiDex issue.

Even though I had enabled MultiDex by giving

  • multiDexEnabled true in Module gradle file under "defaultConfig" for API 21+
  • "implementation 'com.android.support:multidex:1.0.3'" in Module gradle file under "dependencies" for API 20 and below my app failed with the above exception.

I had to make changes to the manifest file and replaced the fully qualified class name of my app with "android.support.multidex.MultiDexApplication"

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">
    <application
            android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>
</manifest>

Please read this page on Multidex for further details. And here is the reference for the application attribute. I have tested my app in the Firebase test labs and physical devices and it works on all versions from API 17 to API 28.




回答2:


Check this first

defaultConfig {
 multiDexEnabled true
}
dependencies {
 implementation 'androidx.multidex:multidex:2.0.1'
}

Then in Application class adding this solved this problem

 @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }


来源:https://stackoverflow.com/questions/44170073/firebase-performance-crashing-in-api-19-with-google-play-services-10-2-98

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!