小编sbd*_*bd2的帖子

Flutter 调试错误“Gradle build 无法生成 .apk 文件”

当尝试在 Android 模拟器上调试我的 Flutter 应用程序时,出现以下错误:

Gradle build failed to produce an .apk file. It's likely that this file was generated under <project_folder>\app\build, but the tool couldn't find it.
Run Code Online (Sandbox Code Playgroud)

我一直在 StackOverflow 和 GitHub 上爬行以找到根本原因,但找不到任何有效的方法。

我在许多帖子中看到,这种行为可能是由于运行调试时未指定的应用程序风格造成的,但我根本没有定义任何风格。

我尝试创建一个全新的项目并将代码粘贴回 lib 文件夹,但没有任何改变。

命令flutter build appbundle也会失败,因此当我想生成应用程序包时,我必须通过 Android Studio 来完成(我使用 VS Code 进行编码)。

我能让这个应用程序在调试模式下工作的唯一方法是切换回调试模式,flutter version 1.9.1+hotfix.6这非常烦人,因为我有另一个运行良好的应用程序,并且我必须使用最新版本进行开发。

这是我的app/build.gradle文件:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if …
Run Code Online (Sandbox Code Playgroud)

android gradle flutter

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

flutter ×1

gradle ×1