Unable to get provider com.google.firebase.perf.provider.FirebasePerfProvider on pre-lollipop devices
Asked Answered
S

3

6

On all versions before v21 (i.e. 16-19), my app crashes on start because of the following error:

E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to get provider com.google.firebase.perf.provider.FirebasePerfProvider: java.lang.ClassNotFoundException: com.google.firebase.perf.provider.FirebasePerfProvider
    at android.app.ActivityThread.installProvider(ActivityThread.java:4563)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4190)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4132)
    at android.app.ActivityThread.access$1300(ActivityThread.java:130)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4745)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.ClassNotFoundException: com.google.firebase.perf.provider.FirebasePerfProvider
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    at android.app.ActivityThread.installProvider(ActivityThread.java:4548)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4190) 
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4132) 
    at android.app.ActivityThread.access$1300(ActivityThread.java:130) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:137) 
    at android.app.ActivityThread.main(ActivityThread.java:4745) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:511) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
    at dalvik.system.NativeStart.main(Native Method) 

On Android 5 and up, my app works without any issues.

I am targeting SDK version 27 and my minimum version is 14. Yes, I have also enabled Multidex support. I have seen some answers about that, but they aren't relevant to my issue as I have this enabled for years already. Currently I am also using Firebase services 11.8.0, the latest.

Seafaring answered 21/1, 2018 at 19:43 Comment(0)
S
10

Fixed it!

Although I had multidex imported and enabled in Gradle, I had to change my Application class to extend MultidexApplication instead of Application.

Hope it helps others too!

Seafaring answered 21/1, 2018 at 22:42 Comment(1)
I have the same problem, but i'm already had the MultidexApplication defined. I do not have any answer how to fix it yetWolgast
X
1

Thanks for the MultiDex tip, which didn't fix this problem for me, but was useful anyway.

What fixed it for me was, in my app build.gradle moving

apply plugin: 'com.google.firebase.firebase-perf'

to be before the following:

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'

In other words, applying firebase-perf as early as possible, but after 'com.android.application'.

Sharing here in case this works for anyone else.

Xylene answered 28/10, 2019 at 12:27 Comment(0)
T
1

I try to remove

apply plugin: 'com.google.firebase.firebase-perf'

at build.gradle and then re-add that, it's solved for me

Trihydric answered 11/9, 2021 at 19:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.