修改compileSdkVersion与targetSdkVersion至34后出现AAPT2构建错误
升级compileSdkVersion和targetSdkVersion到34后出现AAPT2构建错误
原本运行正常的应用,在将compileSdkVersion和targetSdkVersion修改为34后,出现以下构建错误:
Execution failed for task ':app:processDebugResources'. > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction > AAPT2 aapt2-4.2.2-7147631-osx Daemon #0: Unexpected error during link, attempting to stop daemon. This should not happen under normal circumstances, please file an issue if it does.
已尝试的解决方案:
- 清除缓存并重启IDE
- 修改buildTools版本
- 清理项目
- 参考相关Stack Overflow回答调整配置
- 修改gradle.properties文件中的
org.gradle.jvmargs=-Xmx4608m配置 - 查看另一篇Stack Overflow回答,但因应用未拆分模块无法适用
- 尝试升级至gradle-8.3,却出现新错误:
Failed to notify dependency resolution listener. org.gradle.api.artifacts.DependencySubstitutions$Substitution.with(Lorg/gradle/api/artifacts/component/ComponentSelector;)V
之前应用使用targetSdkVersion 30和compileSdkVersion 33,但Google Play要求应用适配API级别31或更高,必须发布更新。
以下是app模块build.gradle配置:
plugins { id 'com.android.application' // Add the Google services Gradle plugin id 'com.google.gms.google-services' } android { compileSdkVersion 34 buildToolsVersion "34.0.0" defaultConfig { applicationId "com..." minSdkVersion 19 targetSdkVersion 34 versionCode 10 versionName "10.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } }
内容的提问来源于stack exchange,提问作者Lekan
相关产品推荐
相关产品推荐

