11

本周我开始在我的新应用中测试新的 Firebase 性能。一旦我将 Firebase 用于 Auth 和 DB 等其他功能,我已经将所有软件包更新到最新的 10.2.6 Firebase 版本并遵循所有 pre req 说明。

minAPI 是 19。

我的问题是应用程序仅在运行 Android 4.4.1 的真实 Galaxy Duos 设备中使用 Google Play 服务 10.2.98 在 API 19 中崩溃。当应用程序启动时,它在设备中找不到 firebase-perf。

这只发生在这个包中,在其他设备和更高版本中一切都很好,我可以在 Firebase Performance Dashboard 中看到数据。

提示 ?

下面的堆栈跟踪

问候,

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) 
4

2 回答 2

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.

于 2019-01-24T17:30:02.393 回答
1

先检查这个

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

然后在应用程序类中添加这个解决了这个问题

 @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
于 2019-11-28T13:03:42.467 回答