问题描述
在路径:DexPathList [[zip文件“ /data/app/com.birthday.photoframe.birthday_frames.birthday_cake-1/base”中找不到类“ com.google.android.gms.common.internal.zzaa” .apk“],nativeLibraryDirectories = [/ data / app / com.birthday.photoframe.birthday_frames.birthday_cake-1 / lib / arm64,/ system / lib64,/ vendor / l
这是我的build.gradle文件
android {
compileSdkVersion 30
buildToolsversion "29.0.3"
defaultConfig {
applicationId "com.birthday.photoframe.birthday_frames.birthday_cake"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true //addded
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-
optimize.txt'),'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
} }
dependencies {
implementation 'com.android.support:multidex:2.0.0'
implementation filetree(dir: "libs",include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.google.android.material:material:1.2.1'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.google.android.gms:play-services-ads:19.3.0'
implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation 'com.google.android.gms:play-services-appindexing:9.8.0'
}
解决方法
尝试将此依赖项添加到gradle文件中:
implementation 'com.android.support:multidex:1.0.3'
此外,您应该对支持和播放服务库使用相同的版本。而且,您应避免在最新版本中使用“ +”。
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
编辑:您也可以将此部分添加到应用程序级别gradle文件中,然后重试。我没有看到任何人尝试过此方法,但它可能有效。
allprojects {
repositories {
//...
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.google.android.gms'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "12.0.1"
}
}
}
}
}
2ND UPDATE:刚刚看到了这一点,下面的依赖项覆盖了所有其他依赖项,因此可能会导致重复问题。删除其他依赖项并保留此依赖项:
implementation 'com.google.android.gms:play-services:12.0.1'