我收到此错误:
1,2,3,4,5,6,7,8,9,4
这是完整的输出:
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/Function;
我认为需要我的build.gradle,所以这是我的build.gradle(Project:test):
2018-11-09 18:33:22.546 24224-24224/com.test.notes.notes E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test.notes.notes, PID: 24224
java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
at com.google.android.gms.internal.firebase-firestore.zzkj.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:6274)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/Function;
at com.google.android.gms.internal.firebase-firestore.zzfu.zzd(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzeg.<init>(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzcj.zza(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzcl.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.android.gms.internal.firebase-firestore.zzkg$zza.run(Unknown Source)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.util.Function" on path: DexPathList[[zip file "/data/app/com.test.notes.notes-1/base.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.test.notes.notes-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.test.notes.notes-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.android.gms.internal.firebase-firestore.zzfu.zzd(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzeg.<init>(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzcj.zza(Unknown Source)
at com.google.android.gms.internal.firebase-firestore.zzcl.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.android.gms.internal.firebase-firestore.zzkg$zza.run(Unknown Source)
at java.lang.Thread.run(Thread.java:761)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.test.notes.notes-1/split_lib_slice_7_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:367)
at dalvik.system.DexFile.<init>(DexFile.java:112)
at dalvik.system.DexFile.<init>(DexFile.java:77)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:359)
at dalvik.system.DexPathList.makeElements(DexPathList.java:323)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:263)
at dalvik.system.DexPathList.<init>(DexPathList.java:126)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
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:58)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:541)
2018-11-09 18:33:22.546 24224-24224/com.test.notes.notes E/AndroidRuntime: at android.app.LoadedApk.getClassLoader(LoadedApk.java:574)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:1900)
at android.app.LoadedApk.getResources(LoadedApk.java:787)
at android.app.ContextImpl.<init>(ContextImpl.java:2038)
at android.app.ContextImpl.createAppContext(ContextImpl.java:1983)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5439)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1576)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:6274)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
出现该错误,应用崩溃。
我认为firebase SDK可能有什么问题,但无法弄清楚吗?
请帮助我解决此问题。很长时间以来,我一直没有找到解决它的方法。:(
编辑:
将所有内容更新到最新版本并添加后:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.test.notes.notes"
minSdkVersion 16
targetSdkVersion 27
versionCode 17
versionName "5.1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
}
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support:support-vector-drawable:27.0.2'
implementation 'com.google.firebase:firebase-firestore:15.0.0'
implementation 'com.firebaseui:firebase-ui-firestore:3.1.1'
api 'com.joooonho:selectableroundedimageview:1.0.1'
api 'com.github.bumptech.glide:glide:3.7.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
api 'com.google.firebase:firebase-core:16.0.5'
api 'com.google.firebase:firebase-firestore:15.0.0'
api 'com.google.firebase:firebase-storage:16.0.4'
api 'com.google.firebase:firebase-auth:16.0.5'
api 'com.crashlytics.sdk.android:crashlytics:2.9.5'
}
apply plugin: 'com.google.gms.google-services'
...一切正常。但是现在我有了问题,为什么我最终将版本降级了。请看一下我的问题:我没有得到答复:
Updating code after firebase 16.0.+ update
我可以解决的话,一切都会好起来的。
答案 0 :(得分:1)
我在您的build.gradle
中看到了很多问题。
第一类问题是您的大多数依赖项已经过时了。
firebase-firestore
在17.1.2而非15.0.0上。firebase-ui-firestore
位于4.2.1而非2.1.1。上。glide
位于4.8.0,而不是3.7.0。从属版本通常应该是最新的,但是如果它们来自Google,则绝对 必须是最新的。否则,您将碰到您所遇到的错误类型。
第二个问题是您两次实施firebase-firestore
,一次使用implementation
,一次使用api
。删除其中一个。
一个方便的提示:如果依赖项以黄色突出显示,则表示它已经过时了!单击文本,单击 Alt + Enter 并选择将其更新为最新版本的选项。