简体   繁体   English

Flutter:gradle 构建失败,错误为“评估根项目 'android' 时出现问题 > 配置项目 ':app' 时出现问题。”

[英]Flutter:gradle build failed with error "A problem occurred evaluating root project 'android' > A problem occurred configuring project ':app'."

My flutter app runs fine on the emulator, runs fine on my android when connected via USB, but crashes before opening when updated from the play store.我的 flutter 应用程序在模拟器上运行良好,通过 USB 连接时在我的 android 上运行良好,但从 Play 商店更新时在打开之前崩溃。 Does the same to everyone else that has tried the update.对尝试过更新的其他人也这样做。 So I thought I would try rebuilding as apk and install from firebase distribution.所以我想我会尝试重建为 apk 并从 firebase 发行版安装。

flutter build works fine if i run as appbundle, or apk but only fails on apk --split-per-abi.如果我作为 appbundle 或 apk 运行但仅在 apk --split-per-abi 上失败,flutter build 工作正常。 I am not sure if this error has to do with why it's crashing or if it's a new problem.我不确定这个错误是否与它崩溃的原因有关,或者它是否是一个新问题。

Here is the error I get when running flutter build -v 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

I seem to keep running into other issues related to this being caused by the gradle version or maybe google services version.我似乎一直遇到与此相关的其他问题,这是由 gradle 版本或谷歌服务版本引起的。 I've tried several different versions.我尝试了几个不同的版本。 Currently using https://services.gradle.org/distributions/gradle-6.5-all.zip and目前使用 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'

I also checked the file in the error message, line 646 contains: abiVersionCode * 1000 + variant.versionCode我还检查了错误消息中的文件,第 646 行包含: abiVersionCode * 1000 + variant.versionCode

I've run flutter clean and here is my flutter doctor -v output:我已经运行 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!

Change the version of gradle on android/build.gradle file to 3.5.0.android/build.gradle文件中的 gradle 版本更改为 3.5.0。

buildscript {
repositories {
    google()
    jcenter()
}

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

On android/gradle/wrapper/gradle-wrapper.properties , your distributionUrl should also have the following gradle version.android/gradle/wrapper/gradle-wrapper.properties 上,您的 distributionUrl 也应该具有以下 gradle 版本。

gradle-5.6.2-all.zip

so that you won't run into any other issues.这样您就不会遇到任何其他问题。

Finally, run these commands最后,运行这些命令

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

It should work like a charm!它应该像魅力一样工作! And update Gradle later on when things get little matured and stable.当事情变得不太成熟和稳定时,稍后更新 Gradle。

Update Your Android Phone To Latest Version!将您的 Android 手机更新到最新版本! Or Follow the above solution或者按照上面的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Gradle - 评估根项目时出现问题 (Android) - Gradle - A problem occurred evaluating root project (Android) 评估根项目“android”时出现问题。 配置项目 ':app' 时出现问题 - Problem occurred evaluating root project 'android'. A problem occurred configuring project ':app' 如何修复 gradle 构建错误配置根项目时出现问题? - How to fix gradle build error A problem occurred configuring root project? 配置根项目“android”时出现问题 Flutter - A problem occurred configuring root project 'android' Flutter Build.Gradle 错误 - 评估项目“:app”时出现问题 - Build.Gradle Error - A problem occurred evaluating project ':app' 运行flutter项目时配置根项目'android'出现问题 - A problem occurred configuring root project 'android' when run flutter project gradle ASCII:评估项目“:app”时出现问题 - gradle ASCII: A problem occurred evaluating project ':app' Build.gradle:评估项目“:app”时出现问题 - Build.gradle: A problem occurred evaluating project ':app' 评估根项目“audioplayers”时出现问题。 在 Flutter 项目中应用插件 [id 'kotlin-android'] 失败 - A problem occurred evaluating root project 'audioplayers'. Failed to apply plugin [id 'kotlin-android'] in Flutter Project Gradle 失败评估项目“:app”时出现问题 - Gradle failure A problem occurred evaluating project ':app'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM