【错误记录】Android Studio 编译报错 ( The project is using an incompatible version (AGP 7.4.2) of the Androi )

文章描述了在Mac上创建的Android项目在迁移到Windows时遇到的AndroidGradlePlugin版本不兼容问题,解决方案是将项目的AGP版本从7.4.2降至7.3.1,以匹配AndroidStudioDolphin版本的要求。修改build.gradle文件中的插件版本即可解决问题。





一、报错信息



在 Mac 中创建的 Android Studio 工程 , 将该项目迁移到 Windows 中后 , 报如下错误 :

The project is using an incompatible version (AGP 7.4.2) of the Android Gradle plugin. 
Latest supported version is AGP 7.3.1
See Android Studio & AGP compatibility options.

在这里插入图片描述





二、解决方案



翻译下报错信息 : 您的项目正在使用一个不兼容的 Android Gradle 插件版本(AGP 7.4.2),最新支持的版本是 AGP 7.3.1。

AGP 是 Android Gradle Plugin 的简写 ;

上述报错的原因是 Android Studio 开发环境 与 Android Gradle 插件 版本不兼容导致的 ;

Android Gradle 插件和 Android Studio 兼容性 文档中 , 给出了 Android Studio 与 Android Gradle 插件 的 兼容版本情况 :

Android Studio 版本所需 Android Gradle 插件版本
Giraffe | 2022.3.13.2-8.1
Flamingo | 2022.2.13.2-8.0
Electric Eel | 2022.1.13.2-7.4
Dolphin | 2021.3.13.2-7.3
Chipmunk | 2021.2.13.2-7.2
Bumblebee | 2021.1.13.2-7.1
Arctic Fox | 2020.3.13.1-7.0

选择 " 菜单栏 / Help / About " 选项 ,

在这里插入图片描述
可以查看当前的 Android Studio 版本号 ;

Android Studio Dolphin | 2021.3.1 Patch 1
Build #AI-213.7172.25.2113.9123335, built on September 30, 2022
Runtime version: 11.0.13+0-b1751.21-8125866 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 16
Registry:
    external.system.auto.import.disabled=true
    ide.text.editor.with.preview.show.floating.toolbar=false
    ide.images.show.chessboard=true

Non-Bundled Plugins:
    com.duke.screenmatch (3.1)
    Dart (213.7433)
    io.flutter (71.2.3)

在这里插入图片描述

当前 Android Studio 的版本号是 " Android Studio Dolphin | 2021.3.1 Patch 1 " , 与之匹配的 Android Gradle 插件版本是 " 3.2-7.3 " ;

使用该 " Android Studio Dolphin " 版本的 Android Studio , 最高只能配置的 Android Gradle 插件的版本为 7.3.1 ;


在 Mac 中创建的项目 , 自动生成的 Android Gradle 插件 版本是 7.4.2 , 说明 Mac 中项目版本号是 " Electric Eel | 2022.1.1 " 或者更高的版本 ;


将 build.gradle 构建脚本中的 com.android.application 插件 和 com.android.library 插件的版本修改为 7.3.1 , 即可完成编译 ;

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
}

在这里插入图片描述

评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值