Android项目AGP版本不兼容求助:无法适配支持的AGP 8.0.2版本
解决Android Gradle插件(AGP)版本不兼容问题
报错明确指出项目使用的AGP 8.2.0-alpha10为预览版,与当前环境支持的最新稳定版8.0.2不兼容,直接降级AGP版本即可解决,同时需同步调整相关依赖版本:
修改步骤
- 将
buildscript块中的AGP版本替换为8.0.2 - 将
plugins块中所有com.android.application和com.android.library的版本替换为8.0.2 - 同步
org.jetbrains.kotlin.plugin.serialization的版本与Kotlin主版本一致(原Kotlin版本为1.8.0,因此序列化插件版本也改为1.8.0)
修改后的完整根目录build.gradle代码
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:8.0.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { id 'com.android.application' version '8.0.2' apply false id 'com.android.library' version '8.0.2' apply false id 'org.jetbrains.kotlin.android' version '1.8.0' apply false id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.0' } tasks.register('clean') { delete rootProject.buildDir }
修改完成后,点击Android Studio右上角的"Sync Now"按钮同步项目,即可解决版本不兼容问题。
内容的提问来源于stack exchange,提问作者Oscar Rangel
相关产品推荐
相关产品推荐

