如何修复com.google.android.play:core:1.10.3与Android 14兼容问题?
上传应用至Google Play Console时的Play Core库兼容错误
请将您的com.google.android.play:core:1.10.3 Maven依赖项更新为兼容Android 14的版本!您当前的com.google.android.play:core:1.10.3库与targetSdkVersion 34(Android 14)不兼容,该版本对广播接收器引入了向后不兼容的变更。提醒您,自2024年8月31日起,Google Play要求所有新应用版本必须适配Android 14。请更新至最新库版本以避免应用崩溃。
我尝试了所有已知方法仍无法解决该问题,以下是我的app模块build.gradle代码:
apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' android { buildFeatures { viewBinding true } compileSdkVersion 34 defaultConfig { minSdkVersion 23 targetSdkVersion 34 versionCode 7 versionName "1.6" multiDexEnabled true vectorDrawables.useSupportLibrary = true 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 } packagingOptions { resources { excludes += ['META-INF/NOTICE.md', 'META-INF/LICENSE.md'] } } lint { abortOnError false checkReleaseBuilds true } namespace 'com.darsenizami.ahyaululoom' } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) // AndroidX dependencies implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'com.google.android.material:material:1.12.0' implementation 'androidx.vectordrawable:vectordrawable:1.2.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.navigation:navigation-fragment:2.7.7' implementation 'androidx.navigation:navigation-ui:2.7.7' implementation 'androidx.recyclerview:recyclerview:1.3.2' implementation 'androidx.multidex:multidex:2.0.1' implementation "androidx.palette:palette:1.0.0" implementation 'androidx.preference:preference:1.2.1' // Firebase Messaging inappmessaging implementation 'com.google.firebase:firebase-messaging' implementation 'com.google.firebase:firebase-inappmessaging-display:21.0.0' // Firebase database implementation 'com.google.firebase:firebase-storage:21.0.0' implementation 'com.google.firebase:firebase-core:21.1.1' implementation 'com.google.firebase:firebase-config:22.0.0' implementation 'com.firebaseui:firebase-ui-database:8.0.2' implementation 'com.google.firebase:firebase-database:21.0.0' // Firebase dependencies with BOM implementation platform('com.google.firebase:firebase-bom:33.1.2') implementation 'com.google.firebase:firebase-messaging' implementation 'com.google.firebase:firebase-inappmessaging-display' implementation 'com.google.firebase:firebase-storage' implementation 'com.google.firebase:firebase-core' implementation 'com.google.firebase:firebase-config' implementation 'com.google.firebase:firebase-database' implementation 'com.google.firebase:firebase-analytics' // Firebase UI implementation 'com.firebaseui:firebase-ui-database:8.0.2' implementation 'com.google.firebase:firebase-auth:23.0.0' // Test dependencies testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test:runner:1.6.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' // External libraries implementation 'com.github.mjn1369:prettydialog:1.0.4' implementation 'de.hdodenhof:circleimageview:3.1.0' implementation 'com.github.bumptech.glide:glide:4.16.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0' implementation 'com.github.SanojPunchihewa:InAppUpdater:1.0.5' implementation 'com.github.chrisbanes:PhotoView:2.3.0' implementation 'com.squareup.picasso:picasso:2.71828' implementation 'com.android.volley:volley:1.2.1' implementation files('libs/YouTubeAndroidPlayerApi.jar') implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1' implementation 'com.google.android.gms:play-services-ads:23.2.0' implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar' // Play Core library //noinspection RiskyLibrary implementation 'com.google.android.play:core:1.10.3' }
解决方法
- 更新Play Core直接依赖版本
把依赖中的com.google.android.play:core:1.10.3替换为兼容Android 14的稳定版本,比如1.12.0(或更高官方稳定版):
// Play Core library implementation 'com.google.android.play:core:1.12.0'
- 强制统一所有依赖的Play Core版本
部分第三方库(比如你用的InAppUpdater)可能会间接引入旧版Play Core,导致版本冲突。在dependencies代码块末尾添加以下规则,强制所有依赖使用指定的兼容版本:
configurations.all { resolutionStrategy.force 'com.google.android.play:core:1.12.0' }
- 清理重复的Firebase依赖
你的Firebase依赖存在重复定义(BOM前后都声明了相同的依赖),建议删除BOM之前的单独版本依赖,只保留BOM管理的依赖,避免版本冲突。比如删除以下片段:
// Firebase Messaging inappmessaging implementation 'com.google.firebase:firebase-messaging' implementation 'com.google.firebase:firebase-inappmessaging-display:21.0.0' // Firebase database implementation 'com.google.firebase:firebase-storage:21.0.0' implementation 'com.google.firebase:firebase-core:21.1.1' implementation 'com.google.firebase:firebase-config:22.0.0' implementation 'com.google.firebase:firebase-database:21.0.0'
- 清理缓存并重建项目
执行File > Invalidate Caches...清理IDE缓存,然后依次点击Build > Clean Project和Build > Rebuild Project,确保所有依赖更新生效。
内容的提问来源于stack exchange,提问作者Sehr Mubeen
相关产品推荐
相关产品推荐

