仅在API28中用于FirebaseInitProvider的ClassNotFoundException

时间:2019-01-06 19:52:16

标签: android firebase classnotfoundexception android-multidex

我将Firebase用于少数服务(分析,firestore,崩溃...),并且一切正常。

但是,每当我在API 28设备上启动我的应用程序时,都会出现以下错误:

  

java.lang.RuntimeException:无法获取提供程序   com.google.firebase.provider.FirebaseInitProvider:   java.lang.ClassNotFoundException:找不到类   路径上的“ com.google.firebase.provider.FirebaseInitProvider”:   DexPathList [[zip文件“ / data / app /[...]

这发生在我之前的许多人身上(可以看到herehereherehere),但是没有人描述这种API选择性行为(通常甚至相反,它可以在新的API上运行,而在旧的API上崩溃)。

我可以在一些设备上对此进行测试,然后得到以下结果:

  • 在API 22、23和26(genymotion仿真器)上,它像一个魅力一样工作
  • 它在API 28(仿真器和实际的One Plus 6)上崩溃了

我使用com.getkeepsafe.dexcount插件检查我是否真的不需要multidex。输出如下:

Methods remaining in app-dev-debug.apk: 15744
Fields remaining in app-dev-debug.apk:  33647
Classes remaining in app-dev-debug.apk:  59277

这是我的app模块build.gradle(但随时询问更多代码或其他代码):

apply {
    plugin 'com.android.application'
    plugin 'io.fabric'
    plugin 'realm-android'
    plugin 'com.google.gms.google-services'
    plugin 'com.getkeepsafe.dexcount'
}


android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 28
        versionCode = 54
        versionName = "4.1.0"
        multiDexEnabled false
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            shrinkResources true
            manifestPlaceholders = [crashlyticsEnabled: true]
            ext.enableCrashlytics = true
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    getDefaultProguardFile('proguard-android-optimize.txt'),
                    'proguard-rules.pro'
            signingConfig signingConfigs.seqa_free
        }
        debug {
            debuggable true
            minifyEnabled true
            shrinkResources false
            manifestPlaceholders = [crashlyticsEnabled: false]
            ext.enableCrashlytics = false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    getDefaultProguardFile('proguard-android-optimize.txt'),
                    'proguard-rules.pro'
            //proguard-rules.pro = just one line: "-dontobfuscate"
        }
    }
    flavorDimensions "stage"
    productFlavors {
        dev {
            versionNameSuffix "-dev"
            applicationIdSuffix '.dev'
            resConfigs "fr", "xxhdpi"
        }
        prod {
            signingConfig signingConfigs.seqa_free
        }
    }
    lintOptions {
        disable 'InvalidPackage'
        return void
    }
    dataBinding {
        enabled = true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

realm {
    syncEnabled = true
}

dependencies {//some are defined on the project builde.gradle
    implementation project(path: ':core')
    implementation project(path: ':data')
    implementation project(path: ':crunches')
    //Firebase
    implementation firebaseDependencies.core
    implementation firebaseDependencies.auth
    implementation firebaseDependencies.firestore
    implementation firebaseDependencies.ui_auth
    //support
    implementation supportDependencies.appcompat
    implementation supportDependencies.customtabs
    implementation supportDependencies.preference
    implementation supportDependencies.recyclerview
    implementation supportDependencies.cardview
    implementation supportDependencies.design
    implementation supportDependencies.constraint_layout
    //3 old crashlytics supports...
    implementation supportDependencies.support_v4
    implementation supportDependencies.animated_vector_drawable
    implementation supportDependencies.support_media_compat
    //indispensables
    implementation sharedDependencies.crashlytics
    implementation sharedDependencies.realm
    implementation sharedDependencies.threetenabp
    implementation sharedDependencies.butterknife
    annotationProcessor sharedDependencies.butterknife_annotation
    //Others
    implementation 'com.pavelsikun:material-seekbar-preference:2.3.0'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    implementation 'com.github.bumptech.glide:glide:4.4.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
    implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
    implementation 'com.facebook.stetho:stetho:1.5.0'
    implementation 'com.uphyca:stetho_realm:2.2.2'
}

我尝试了其他问题的答案,例如添加multidex(即使我显然不需要它),但这没有帮助。也不清理我的项目或重建。

API 28可能是什么问题?

0 个答案:

没有答案