我收到 Gradle 任务 assembleDebug 失败,退出代码为 1

i am getting Gradle task assembleDebug failed with exit code 1

嗨,我是 Flutter 的新手,我尝试克隆一个 github 存储库,这是我似乎无法自行解决的错误。

失败:构建失败,出现异常。

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction One or more issues found when checking AAR metadata values:

 The minCompileSdk (31) specified in a
 dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
 is greater than this module's compileSdkVersion (android-29).
 Dependency: androidx.window:window-java:1.0.0-beta04.
 AAR metadata file: C:\Users\alpha\.gradle\caches\transforms-3a83d0cf61e3d2ab42ea706b65148ab\transformed\jetified-window-java-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.

 The minCompileSdk (31) specified in a
 dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
 is greater than this module's compileSdkVersion (android-29).
 Dependency: androidx.window:window:1.0.0-beta04.
 AAR metadata file: C:\Users\alpha\.gradle\caches\transforms-3\bb9a53f8c4dc071c681fa071739dc70b\transformed\jetified-window-1.0.0-beta04\META-INF\com\android\build\gradle\aar-metadata.properties.

1 秒内构建失败 异常:Gradle 任务 assembleDebug 失败,退出代码为 1

打开android/app文件夹下的build.gradle文件,将compileSdkVersion & targetSdkVersion设置为31,将minSdkVersion设置为21,以兼容旧版本android.

的版本

为了安全起见,在重建应用程序之前进行 flutter clean。

另一个值得尝试的快速解决方案(并非每次都有效,但尝试没有坏处)是 运行 命令:

flutter clean

在终端中,然后尝试重新运行该项目。