[Error record] Android Studio compilation error ( The project is using an incompatible version (AGP 7.4.2) of the Androi )





1. Error message



After migrating the Android Studio project created on Mac to Windows, the following error is reported:

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.

insert image description here





Two, the solution



Translate the error message: Your project is using an incompatible version of the Android Gradle plugin (AGP 7.4.2), the latest supported version is AGP 7.3.1.

AGP is short for Android Gradle Plugin;

The reason for the above error is that the Android Studio development environment is not compatible with the Android Gradle plug-in version;

In the Android Gradle Plugin and Android Studio Compatibility document, the compatible versions of Android Studio and the Android Gradle plugin are given:

Android Studio version Required Android Gradle plugin version
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

Select the "Menu Bar / Help / About" option,

insert image description here
You can view the current Android Studio version number;

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)

insert image description here

The current Android Studio version number is "Android Studio Dolphin | 2021.3.1 Patch 1", and the matching Android Gradle plugin version is "3.2-7.3";

Using the "Android Studio Dolphin" version of Android Studio, the highest version of the Android Gradle plugin that can only be configured is 7.3.1;


For projects created on Mac, the automatically generated version of the Android Gradle plugin is 7.4.2, indicating that the version number of the project on Mac is " Electric Eel | 2022.1.1 " or a higher version;


com.android.applicationModify the version of plug-in and plug-in in build.gradle build script com.android.libraryto 7.3.1 to complete the compilation;

// 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
}

insert image description here

Guess you like

Origin blog.csdn.net/han1202012/article/details/130194426