KITKAT error : Unable to get provider com.google.firebase.provider.FirebaseInitProvider:

KITKAT error : Unable to get provider com.google.firebase.provider.FirebaseInitProvider:

我收到 class not found on kitkat and jellybean 的错误。我已经在 jellybean、kitkat Emulators 以及 lollipo 和 marshmellow 物理设备上测试了我的应用程序。

我搜索了很多post但都显示卸载并清除,或者使用play-service-maps而不是play-service。但是我需要使用 play-services 因为标记和所有的东西。 请帮我解决这个问题。

错误

12-12 21:08:59.289 3396-3396/? E/AndroidRuntime: FATAL EXCEPTION: main
                                             Process: com.thetech.ambulancerequest, PID: 3396
                                             java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.thetech.ambulancerequest-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.thetech.ambulancerequest-1, /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.access00(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.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.thetech.ambulancerequest-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.thetech.ambulancerequest-1, /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.access00(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)

这是我的 app>gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"
    defaultConfig {
        applicationId "com.thetech.ambulancerequest"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        setProperty("archivesBaseName", "Ambulance Requests-$versionName")
        multiDexEnabled true
    }

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'eu.the4thfloor.volley:com.android.volley:2015.05.28'
    compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

SplashSvcreen

 @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSupportActionBar().hide();
        setContentView(R.layout.activity_splash);
        MultiDex.install(this);

在您的 build.gradle

上更改此设置
compile 'com.google.android.gms:play-services:10.0.1'

为此:

compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.android.gms:play-services-places:10.0.1'

请注意,the documentation 建议仅依赖于必要的 Play 服务模块,而不是依赖于整个 Play 服务库:

If the number of method references in your app exceeds the 65K limit, your app may fail to compile. You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them. For information on how to do this, see Selectively compiling APIs into your executable.