Firebase Performance crashing in API 19 with Google Play Services 10.2.98
Asked Answered
I

2

11

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) 
Inconceivable answered 24/5, 2017 at 23:32 Comment(10)
Prompt the user to update Google Play Services before proceed? Blacklist the device from the Google Play Console to prevent the downloads?Demission
It still in dev. I can do both your suggestions, but what is strange Firebase documentation require minimal version 10.2.6 and device version is higher 10.2.98.Inconceivable
Oh, if you are in dev you can't say for sure that the problem is the device or your implementation (which maybe need a custom tweak in some cases). Or you have used some online services to perform tests on hundreds of devices?Demission
I have tested in a lot of REAL devices, Samsung (S5, S6, S7,J5,J7, Galaxy Duos), LG (K10), Motorola (G4, G5), Blue, Sony Z, with Android 4.4, 6.x, 5.x, 5.1x, 7.x. I tested in dozen of emulator configs from API 19 to 24 using Google SDK. I tested in TestLab Real devices and emulators from API 19 to 23. All emulators with API 19, local and google, I got same error.Inconceivable
To verify that is not a problem in my code or emulator config I got a real device with API 19 with is one Samsung Galaxy Duos with API 19 as well I tested in Google TestLab for real devices with API 19. The App ONLY crash in devices with API 19, doesn't matter if it is emulator or real.Inconceivable
I have other 10 Firebase packages, Auth, DB, Storage, Config, Ads, etc, etc, and only Performance is failingInconceivable
If you're seeing a crash, you should post a stack trace so we can see what's going on.Incurious
Very similar looking stack traces (although for different missing class) have been corrected by enabling Multidex. From your previous comment ("10 Firebase packages"), it sounds like your app could be very large. Try using the APK Analyzer to see if you need Multidex.Scrimpy
Thanks @BobSnyder. I SOLVED the problem but I confess I did not understand the solution :-). I was using "@AddTrace" directive to instrument my code. In APK Analyzer I saw AddTrace was used but other named AppTraceStart is not. I changed my code and removed "@AddTrace" directive and started use Trace class with .start(), etc. For some reason it is working in API 19 and other versions too. I will make more tests later.Inconceivable
@Inconceivable Would you mind reaching out to Firebase support with a minimal project that reproduces the problem, and link back to this post? firebase.google.com/support/contact/troubleshootingIncurious
T
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.

Testudo answered 24/1, 2019 at 17:30 Comment(0)
P
1

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);
    }
Putter answered 28/11, 2019 at 13:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.