Flutter 项目构建失败并显示错误消息:-
Posted
技术标签:
【中文标题】Flutter 项目构建失败并显示错误消息:-【英文标题】:Flutter project build failed with error message:- 【发布时间】:2020-05-14 18:07:25 【问题描述】:Build file 'C:\Users\amani\Desktop\expenseapp\android\build.gradle' line: 24
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> Failed to find target with hash string 'android-28' in: C:\Users\amani\AppData\Local\Android\Sdk
* 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.
Launching lib\main.dart on ALE L21 in debug mode...
FAILURE: Build failed with an exception.
* Where:
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
而android\build.gradle如下:
buildscript
repositories
google()
jcenter()
dependencies
classpath 'com.android.tools.build:gradle:3.2.1'
allprojects
repositories
google()
jcenter()
rootProject.buildDir = '../build'
subprojects
project.buildDir = "$rootProject.buildDir/$project.name"
subprojects
project.evaluationDependsOn(':app')
task clean(type: Delete)
delete rootProject.buildDir
谁能帮我解决这个问题?我尝试了许多其他在网上找到的解决方案,但似乎没有任何效果,而且我不知道该怎么做才能使这项工作发挥作用。
运行颤振医生命令返回:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.18363.592], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.5)
[√] VS Code (version 1.41.1)
[√] Connected device (1 available)
• No issues found!
【问题讨论】:
如果您使用的是android studio,请尝试在终端中使用flutter clean命令,然后重建项目 【参考方案1】:在您的 android/app/build.gradle
文件中,将 compileSdkVersion
从 28 更改为 29,将 targetSdkVersion
从 28 更改为 29。
然后,再次重建项目。
【讨论】:
@AmaniSaaduddin 在 android studio 中单独打开 android 文件夹并尝试构建,在那里你会得到帮助你解决它的确切原因。 感谢您抽出时间和回答,我更新了我的 Android SDK 并安装了 JDK 8,现在它可以正常工作了。 @AmaniSaaduddin 如果您认为有帮助,请随时接受我的回答。谢谢。以上是关于Flutter 项目构建失败并显示错误消息:-的主要内容,如果未能解决你的问题,请参考以下文章
Flutter:我在将flutter_local_notification添加到依赖项后尝试构建一个项目,但失败了