android firebase运行时异常:未找到类“com.google.firebase.provider.FirebaseInitProvider”

时间:2017-07-21 06:08:57

标签: android firebase

我在我的应用程序中使用firebase进行电话号码验证。在我的手机中工作正常(版本:LOLLIPOP)。当我试图在另一个移动设备上运行它(版本:JELLYBEAN)时,它会在应用程序的开头显示“不幸停止”.Below是我在logcat中获得的异常。

例外:

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: /data/app/com.example.jobinsabu.ohxee-2.apk
                                                                                 at android.app.ActivityThread.installProvider(ActivityThread.java:5022)
                                                                                 at android.app.ActivityThread.installContentProviders(ActivityThread.java:4631)
                                                                                 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4571)
                                                                                 at android.app.ActivityThread.access$1400(ActivityThread.java:157)
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                 at android.os.Looper.loop(Looper.java:176)
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5317)
                                                                                 at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                 at java.lang.reflect.Method.invoke(Method.java:511)
                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
                                                                                 at dalvik.system.NativeStart.main(Native Method)
                                                                              Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: /data/app/com.example.jobinsabu.ohxee-2.apk
                                                                                 at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
                                                                                 at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
                                                                                 at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
                                                                                 at android.app.ActivityThread.installProvider(ActivityThread.java:5007)
                                                                                 at android.app.ActivityThread.installContentProviders(ActivityThread.java:4631) 
                                                                                 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4571) 
                                                                                 at android.app.ActivityThread.access$1400(ActivityThread.java:157) 
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349) 
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                                 at android.os.Looper.loop(Looper.java:176) 
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5317) 
                                                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                 at java.lang.reflect.Method.invoke(Method.java:511) 
                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 
                                                                                 at dalvik.system.NativeStart.main(Native Method) 

OTP.java:

PhoneAuthProvider.getInstance().
verifyPhoneNumber(phnmbr,60,TimeUnit.SECONDS,getActivity(),onVerificationStateChangedCallbacks);

                 onVerificationStateChangedCallbacks=new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
                                    @Override
                      public void onVerificationCompleted(PhoneAuthCredentiaphoneAuthCredential)           {
                         Log.e("OTP","Success");

                         }
                        @Override
                        public void onVerificationFailed(FirebaseException e)
                        {
                         Log.e("OTP","Failed");
                         }

                 @Override
                 public void onCodeSent(String s,PhoneAuthProvider.ForceResendingToken forceResendingToken) 
                {
                  super.onCodeSent(s, forceResendingToken);
                 Log.e("Code","Sent");
                                    }

                 @Override
                 public void onCodeAutoRetrievalTimeOut(String s) {
                  super.onCodeAutoRetrievalTimeOut(s);
                                    }
                                };

的build.gradle:

apply plugin: 'com.android.application'


android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.example.jobinsabu.ohxee"
        minSdkVersion 16
        targetSdkVersion 25
        multiDexEnabled true

        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    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.constraint:constraint-layout:1.0.2'
    compile 'com.borax12.materialdaterangepicker:library:1.9'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.patrickpissurno:ripple-effect:1.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.android.gms:play-services-maps:11.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.github.darsh2:MultipleImageSelect:3474549'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.sa90.materialarcmenu:library:1.4'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.google.firebase:firebase-auth:11.0.1'
    compile 'org.jetbrains:annotations-java5:15.0'
    compile 'com.google.android.gms:play-services:11.0.2'
    compile 'com.google.firebase:firebase-messaging:11.0.2'
}
apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:1)

  

在   dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)

您应该修改模块级 build.gradle 文件以启用 multidex 并添加 Multidex库作为依赖

 android 
 {
    defaultConfig 
    {
        ...
        minSdkVersion // 
        targetSdkVersion //
        multiDexEnabled true // Add this 
    }
    ...
}

 dependencies 
 {
  compile 'com.android.support:multidex:1.0.1' // Include this
 }

<强> FYI

使用相同版本

compile 'com.google.firebase:firebase-auth:11.0.2'