Flutter:Gradle 构建未能生成 .apk 文件.这个文件很可能是在<app_root>\build下生成的,但是工具找不到 [英] Flutter: Gradle build failed to produce an .apk file. It's likely that this file was generated under <app_root>\build, but the tool couldn't find it

查看:48
本文介绍了Flutter:Gradle 构建未能生成 .apk 文件.这个文件很可能是在<app_root>\build下生成的,但是工具找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试试驾一个应用.由于应用程序无法调试/运行,我一直遇到这个问题的奇怪问题.SDK 版本为 28,其余版本如下:

I am trying to test drive an app. I keep getting a strange issue with this problem as app fail to debug/run. SDK version is 28 while the rest is below:

Flutter 1.13.9-pre.79 • channel master • https://github.com/flutter/flutter.git
Framework • revision 9eb9ea0ffa (6 hours ago) • 2020-01-13 21:30:42 -0800
Engine • revision 0235a50843
Tools • Dart 2.8.0 (build 2.8.0-dev.0.0 28c335d5a2)

Gradle 构建未能生成 .apk 文件.这很可能文件是在 C:\Development\\build 下生成的,但是工具找不到.

Gradle build failed to produce an .apk file. It's likely that this file was generated under C:\Development\\build, but the tool couldn't find it.

有没有办法通过提供或将输出路径提供给 Gradle 来传递这个问题或允许我运行的配置?.apk 似乎是在错误状态下生成的.

Is there a way to pass this issue or a configuration that can allow me to run by providing or giving the output path to Gradle? The .apk seems to generated as the error states.

更新:

Android Studio -v 3.5.3 
Gradle -v 3.4.2 
Gradle Wrapper -v 5.1.1

推荐答案

就我而言,我有一个像这样的多口味应用:

in my case I have a multi flavor app like this:

2021 年 4 月 15 日更新:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
            {
                    "name": "YOUR_PROJECT_NAME",
                    "program": "lib/main.dart",
                    "request": "launch",
                    "type": "dart",
                    "args": [
                            "--flavor",
                            "ADD_YOUR_FLAVOR_NAME_HERE" //development or staging or production
                        ]
            }
    ]

另一种方式:

 android {

    ...

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }

    flavorDimensions "flavor-type"

    productFlavors{
        development{
            dimension "flavor-type"
        }
        staging{
            dimension "flavor-type"
        }
        production{
            dimension "flavor-type"
        }
    }
}

因此,如果您想运行应用程序,您必须编写风味名称,然后编写包含 main() 函数的类名

So if you want to run app you have to write the flavor name and then the class name that hold main() function

flutter run --flavor staging -t lib/main_staging.dart

我解决了我的错误并构建了 .apk

and I solved my error and built the .apk

这篇关于Flutter:Gradle 构建未能生成 .apk 文件.这个文件很可能是在<app_root>\build下生成的,但是工具找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆