目前我的应用minSdkVersion 15
。一切都很好。根据我要添加到我的应用中的内容,我需要multidex
或minSdkVersion 21
或更高版本。无论哪种方式我尝试,我的应用程序崩溃给我这个错误。
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzab;
04-04 13:14:09.612 20274 20274 E AndroidRuntime at com.google.firebase.provider.FirebaseInitProvider.zza(Unknown Source:2)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:0)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at android.app.ActivityThread.installProvider(ActivityThread.java:6572)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at android.app.ActivityThread.installContentProviders(ActivityThread.java:6127)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6037)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at android.app.ActivityThread.-wrap1(Unknown Source:0)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:105)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at android.os.Looper.loop(Looper.java:164)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:6938)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at java.lang.reflect.Method.invoke(Native Method)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
04-04 13:14:09.612 20274 20274 E AndroidRuntime Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzab" on path: DexPathList[[zip file "/data/app/com.JEB.trailmaps-USsJPJClgRBZb0OXtU0Gmg==/base.apk"],nativeLibraryDirectories=[/data/app/com.JEB.trailmaps-USsJPJClgRBZb0OXtU0Gmg==/lib/arm64, /data/app/com.JEB.trailmaps-USsJPJClgRBZb0OXtU0Gmg==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
04-04 13:14:09.612 20274 20274 E AndroidRuntime at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
04-04 13:14:09.612 20274 20274 E AndroidRuntime at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
我没有添加任何依赖项就得到了。我所做的就是将minSdkVersion
更改为21.我通过Google找到的所有内容都指向需要使用multidex。但我实际上还没有添加任何依赖性来实际需要multidex。当我添加multidex时,我得到相同的日志。
这是我的Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.JEB.trailmaps"
minSdkVersion 15
targetSdkVersion 24
versionCode 533
versionName "5.3.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.1'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.0'
compile 'com.android.support:cardview-v7:25.0.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.firebaseui:firebase-ui-database:0.4.0'
compile "com.google.android.gms:play-services-places:9.4.0"
compile 'com.google.android.gms:play-services-ads:9.4.0'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:2)
我注意到了一些事情:
25.0.0
compileSdkVersion and
targetSdkVersion is 24
build.gradle
文件中,以包含google-services插件和Google's Maven repository buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.2.0' // google-services plugin
}
}
allprojects {
// ...
repositories {
// ...
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
build:gradle:3.0 or higher
please use implementation
代替compile
firebase dependencies
,请务必将其版本更新为google services
的{{3}} Tools -> Android -> SDK Manager -> SDK Tools
中找到它com.firebaseui:firebase-ui-database:0.4.0
阅读更多match version 因此,您的最终Gradle文件应如下所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.3"
defaultConfig {
applicationId "com.JEB.trailmaps"
minSdkVersion 15
targetSdkVersion 26
versionCode 533
versionName "5.3.3"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
mavenCentral()
jCenter()
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.1'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.google.firebase:firebase-database:12.0.0'
implementation 'com.firebaseui:firebase-ui-database:0.4.0'
implementation 'com.google.android.gms:play-services-places:12.0.0'
implementation 'com.google.android.gms:play-services-ads:12.0.0'
implementation 'com.android.support:multidex:1.0.0'
}
apply plugin: 'com.google.gms.google-services'