Flutter:gradle build failed with error "A problem occurred evaluation root project 'android' &g

Posted

技术标签:

【中文标题】Flutter:gradle build failed with error "A problem occurred evaluation root project \'android\' > A problem occurred using project \':app\'."【英文标题】:Flutter:gradle build failed with error "A problem occurred evaluating root project 'android' > A problem occurred configuring project ':app'."Flutter:gradle build failed with error "A problem occurred evaluation root project 'android' > A problem occurred using project ':app'." 【发布时间】:2021-02-13 06:20:46 【问题描述】:

我的 Flutter 应用在​​模拟器上运行良好,通过 USB 连接时在我的 android 上运行良好,但在从 Play 商店更新时在打开之前崩溃。对所有尝试过更新的人都这样做。所以我想我会尝试重建为 apk 并从 firebase 发行版安装。

如果我作为 appbundle 或 apk 运行,flutter 构建工作正常,但仅在 apk --split-per-abi 上失败。 我不确定这个错误是否与它崩溃的原因有关,或者它是否是一个新问题。

这是我在运行 flutter build -v apk --split-per-abi 时遇到的错误

 FAILURE: Build failed with an exception.
[   +1 ms] * Where:
[        ] Script
'/Users/me/development/flutter-3/packages/flutter_tools/gradle/flutter.gradle' line: 646
[        ] * What went wrong:
[        ] A problem occurred evaluating root project 'android'.
[        ] > A problem occurred configuring project ':app'.
[   +1 ms]    > The value for this property cannot be changed any further.
[        ] * Try:
[        ] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to
get more log output. Run with --scan to get full insights.
[        ] * Get more help at https://help.gradle.org
[        ] BUILD FAILED in 1s

我似乎一直遇到与此相关的其他问题,这些问题是由 gradle 版本或谷歌服务版本引起的。我尝试了几个不同的版本。目前使用 https://services.gradle.org/distributions/gradle-6.5-all.zip 和

classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms:google-services:4.1.0'

我还检查了错误消息中的文件,第 646 行包含: abiVersionCode * 1000 + variant.versionCode

我已经运行了flutter clean,这是我的flutter doctor -v 输出:

[✓] Flutter (Channel master, 1.24.0-4.0.pre.167, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en-US)
    • Flutter version 1.24.0-4.0.pre.167 at /Users/me/development/flutter-3
    • Framework revision 22724370cb (54 minutes ago), 2020-10-30 11:00:24 -0700
    • Engine revision 99cc50dfff
    • Dart version 2.11.0 (build 2.11.0-266.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/me/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for ios and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    • CocoaPods version 1.9.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Android Studio (version 3.5)
    • Android Studio at /Users/me/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5900203/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.46.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.12.2

[✓] Connected device (2 available)
    • Web Server (web) • web-server • web-javascript • Flutter Tools
    • Chrome (web)     • chrome     • web-javascript • Google Chrome 86.0.4240.111

• No issues found!

【问题讨论】:

检查一切都是最新的 【参考方案1】:

android/build.gradle 文件上的 gradle 版本更改为 3.5.0。

buildscript 
repositories 
    google()
    jcenter()


dependencies 
    ...
    classpath 'com.android.tools.build:gradle:3.5.0' // Use this version


android/gradle/wrapper/gradle-wrapper.properties 上,您的 distributionUrl 还应具有以下 gradle 版本。

gradle-5.6.2-all.zip

这样您就不会遇到任何其他问题。

最后,运行这些命令

rm -rf android/.gradle
rm -rf $HOME/.gradle # This is for Mac users
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi

它应该像一个魅力!稍后在事情变得不太成熟和稳定时更新 Gradle。

【讨论】:

在第二个 rm 命令中将 // 更改为 #// 实际上是 /,并被 rm 解释为第二个参数,它会尝试 rm -rf 您的整个系统。我认为这是一个无辜的错误。 这实际上只是一个注释,不能在终端中写入。但是谢谢你提到它。 你需要修复它。人们一直从这里剪切和粘贴,如果您剪切和粘贴该文本,您将(我做到了!)立即开始删除系统上的所有文件。将 // 更改为 # 或删除注释。这不是“实际上只是评论” 好的,我将'//这是给Mac用户的'更新为'#这是给Mac用户的'。 感谢 Giri,此过程在我的颤振 aws Congito Auth 项目中运行良好。【参考方案2】:

将您的 Android 手机更新到最新版本! 要么 按照上面的解决方案

【讨论】:

这并没有提供问题的答案。一旦你有足够的reputation,你就可以comment on any post;相反,provide answers that don't require clarification from the asker。 - From Review

以上是关于Flutter:gradle build failed with error "A problem occurred evaluation root project 'android' &g的主要内容,如果未能解决你的问题,请参考以下文章

如何解决flutter gradle build error?C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991

[Flutter] flutter项目一直卡在 Running Gradle task 'assembleDebug'...

构建 appbundle 时出现颤振错误(脚本'/Users/****/Developer/flutter/packages/flutter_tools/gradle/flutter.gradle'

构建失败 - flutter.gradle

VUE 打包 Module build failed: Error: No PostCSS Config found in

任务“:app:compileFlutterBuildDebug”执行失败-flutter.gradle 行:1035