即使添加了Firebase库,我的应用也会由于Firebase存储而崩溃

时间:2019-04-22 17:36:42

标签: java android

当我尝试登录时,我的应用程序崩溃了!当我在模拟器中运行该应用程序时,Logcat会显示错误,但在手机上运行该应用程序时它不会显示错误,并且登录后仍然崩溃

这是我的Home.java部分,其中在第84行显示错误:

FirebaseDatabase database;
    DatabaseReference categories;
    FirebaseStorage storage;
    StorageReference storageReference;
   database=FirebaseDatabase.getInstance();
        categories=database.getReference("Category");
      **Line 84**  storage=FirebaseStorage.getInstance();
        storageReference=storage.getReference();

这是我的Logcat:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.adminpanel, PID: 6433
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzac;
        at com.google.firebase.storage.FirebaseStorage.getInstance(Unknown Source:11)
        at com.example.adminpanel.Home.onCreate(Home.java:84)
        at android.app.Activity.performCreate(Activity.java:6975)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzac" on path: DexPathList[[zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/base.apk", zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_resources_apk.apk", zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/lib/x86, /system/lib, /vendor/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.google.firebase.storage.FirebaseStorage.getInstance(Unknown Source:11) 
        at com.example.adminpanel.Home.onCreate(Home.java:84) 
        at android.app.Activity.performCreate(Activity.java:6975) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6541) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 
        Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.adminpanel-2XG9IS-qGGtwfxmzfIPhbw==/split_lib_resources_apk.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:353)
        at dalvik.system.DexFile.<init>(DexFile.java:100)
        at dalvik.system.DexFile.<init>(DexFile.java:74)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
        at dalvik.system.DexPathList.<init>(DexPathList.java:157)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
        at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:36)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:676)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:709)
        at android.app.LoadedApk.getResources(LoadedApk.java:936)
E/AndroidRuntime:     at android.app.ContextImpl.createAppContext(ContextImpl.java:2242)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5672)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
                ... 6 more

我确实添加了这些库:

 implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-storage:10.2.0'
    implementation 'com.google.firebase:firebase-auth:10.2.0'

1 个答案:

答案 0 :(得分:0)

我不确定,但这可能有用。

implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.2.1'
implementation 'com.google.firebase:firebase-storage:16.1.0'
implementation 'com.google.firebase:firebase-database:16.1.0'