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

一、报错信息


在 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.1 3.2-8.1
Flamingo | 2022.2.1 3.2-8.0
Electric Eel | 2022.1.1 3.2-7.4
Dolphin | 2021.3.1 3.2-7.3
Chipmunk | 2021.2.1 3.2-7.2
Bumblebee | 2021.1.1 3.2-7.1
Arctic Fox | 2020.3.1 3.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
}

在这里插入图片描述

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码

)">
< <上一篇
下一篇>>