应用程序在Android

时间:2016-09-05 08:09:47

标签: android firebase android-gradle

在jellybean或更低版本的API中启动应用程序时,gradle会发出此错误。

09-05 03:53:20.660 6775-6775/com.example.MyApp E/AndroidRuntime: FATAL EXCEPTION: main
 java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions
     at com.google.firebase.FirebaseApp.zzek(Unknown Source)
     at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
     at android.content.ContentProvider.attachInfo(ContentProvider.java:1214)
     at android.content.ContentProvider.attachInfo(ContentProvider.java:1189)
     at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
     at android.app.ActivityThread.installProvider(ActivityThread.java:4879)
     at android.app.ActivityThread.installContentProviders(ActivityThread.java:4485)
     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4425)
     at android.app.ActivityThread.access$1300(ActivityThread.java:141)
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
     at android.os.Handler.dispatchMessage(Handler.java:99)
     at android.os.Looper.loop(Looper.java:137)
     at android.app.ActivityThread.main(ActivityThread.java:5103)
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:525)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
     at dalvik.system.NativeStart.main(Native Method)

我的gradle.app

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.example.MyApp"
        minSdkVersion 12
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
        transitive = true;
    }
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:cardview-v7:24.2.0'
    compile 'com.android.support:support-v4:24.2.0'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.google.firebase:firebase-core:9.0.0' // Tried with and without this
    compile 'com.android.support:multidex:1.0.1'
}

检查堆栈中提供的每个解决方案是否过流但是没有工作。

我的Google存储库和Google Play服务已更新。

1 个答案:

答案 0 :(得分:1)

将此属性添加到清单中的应用程序标记:

android:name="android.support.multidex.MultiDexApplication"

从gradle中删除multiDexEnabled true