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

查看:2500
本文介绍了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:

 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天全站免登陆