android - Flutter项目建置失败,并显示错误讯息:-

标签 android gradle flutter build.gradle

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
}

谁能帮我解决这个问题?我已经尝试了许多其他在线解决方案,但是似乎没有任何效果,因此我不知道该怎么做。

运行flutter doctor命令将返回以下内容:
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/app/build.gradle文件中,将compileSdkVersion从28更改为29,并将targetSdkVersion 28 更改为 29

然后,再次重建项目。

关于android - Flutter项目建置失败,并显示错误讯息:-,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59963772/

相关文章:

android - 如何从非 Activity 类访问可绘制对象

java - React-native 添加一个小部件到 android 主屏幕

java - 安卓 flavor : Multiple java and src directories for each flavor

android - 用Android Studio问题启动Flutter

java - 如何在 Sqlite 中搜索字符串值?

java - 如何在ScrollView的底部添加字符串

java - 如何在 Gradle 和 Eclipse 之间同步 Java 源和目标?

gradle - gradle在Ubuntu 16.04中未正确安装

flutter - 无法通过从API提取数据来获取ID

google-app-engine - Google Cloud Storage 的速度是否足以向移动应用程序提供图像?