简体   繁体   English

更改配置flutter build apk,找不到目标文件“lib/main.dart”

[英]change configuration flutter build apk, Target file "lib/main.dart" not found

Hey guys how to i changing target flutter build apk cause i getting error target file not found on console:嘿伙计们,我如何更改目标颤振构建 apk 导致我在控制台上找不到错误目标文件:

(base) dendimuhmd@mbp-dendimuhmd makanyuk % flutter build apk --release            
Target file "lib/main.dart" not found.

Folder structure文件夹结构

Your main.dart file is located in lib/src folder.您的main.dart文件位于lib/src文件夹中。 It is required to be in lib folder to work properly.它需要在lib文件夹中才能正常工作。 The following is mentioned in the docs of Flutter VS code extension website. Flutter VS 代码扩展网站的文档中提到了以下内容。

Flutter entry points should be at lib/main.dart Launch Configuration Flutter 入口点应该在 lib/main.dart启动配置

The following are the possible configuration on the website.以下是网站上可能的配置。

"configurations": [
    {
        // A name for the launch config. This will show in the dropdown on the Run side bar.
        "name": "Current File (release mode)",

        // This should always be "dart" for Dart/Flutter apps.
        // This selects the Dart debugger.
        "type": "dart",

        // This can be "launch" to start an app, or "attach" to attach to an existing app.
        "request": "launch",

        // The directory to start running the app from.
        "cwd": "/foo/bar",

        // The entry script to execute when running the app.
        // Set to a "web" in a Dart web app to run in web move.
        // Set to "test" in an app with tests to run all tests.
        "program": "bin/main.dart",

        // Any custom environment variables to set when running the app with this
        // launch config.
        "env": {
            "RELEASE_MODE": true
        }

        // Arguments to be passed to the Dart or Flutter app.
        "args": [
            "--dart-define", "MY_VAR=foo"
        ],

        // "debugConsole" or "terminal". If set to "terminal", will run in the built-in
        // terminal and will support reading from `stdin`. However some other debug
        // features may be limited.
        "console": "debugConsole",

        // Set to run a Flutter app on a specific device, ignoring the device selected
        // in the status bar.
        "deviceId": "iphone",

        // "debug", "profile" or "release".
        "flutterMode": "debug",

        // Allows running Flutter tests on a real device instead of the default headless
        // flutter-tester device.
        "runTestsOnDevice": false,

        // If codeLens is defined, this launch configuration can be launched from custom
        // CodeLens links in the editor (see the page linked above for more info).
        "codeLens": {

            // This array sets where custom CodeLens links will be rendered:
            // - run-test: Above test functions as a Run link
            // - debug-test: Above test functions as a Debug link
            // - run-test-file: Above main functions in test files as a Run link
            // - debug-test-file: Above main functions in test files as a Debug link
            // - run-file: Above main functions in bin/tool/lib files as a Run link
            // - debug-file: Above main functions in bin/tool/lib files as a Debug link
            "for": [ "run-test", "run-test-file", "debug-test", "debug-test-file" ],

            // If specificed, the custom CodeLens will only appear for files that begin
            // with this path.
            "path": "test/integration_tests",

            // Text for the custom CodeLens. If not specified, will use the name field
            // from the parent launch configuration. The string "${debugType}" here will
            // be replaced with "run" or "debug" depending on the rendered position
            // (see the for field above).
            "title": "${debugType} (release)"
        },
    }
]

You can use -t to change the target.您可以使用-t更改目标。

The main entry-point file of the application, as run on the device.应用程序的主入口点文件,在设备上运行。 If the "--target" option is omitted, but a file name is provided on the command line, then that is used instead.如果省略“--target”选项,但在命令行上提供了文件名,则使用该文件名。 (defaults to "lib\main.dart") (默认为“lib\main.dart”)

For your case对于您的情况

flutter build apk  -t .\lib\src\main.dart

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 出现“找不到目标文件”lib\main.dart“之类的错误。” 在 flutter 中构建 APK - Getting error like “Target file ”lib\main.dart“ not found.” whlie building APK in flutter 未找到目标文件“lib\main.dart”。 flutter - Target file "lib\main.dart" not found. flutter Flutter:找不到目标文件“lib/main.dart” - Flutter : Target file "lib/main.dart" not found AndroidStudio:在 main.dart 中找不到入口点文件 - AndroidStudio: Entrypoint file not found at main.dart ZC047B10EEEE763AFB6164E07CF1CC268Z:我更改了Z35900D987289A89A83AF101D18A9F7C3501Z入口处login.zbbbb14127678960e171777897d8739501595015950101595010150150150150101010101010101010101010101010年, - Flutter: I have changed the Dart entrypoint to Login.dart , while building apks error shows that lib\main.dart not found 如何修复 flutter lib/main.dart 错误 - How to fix flutter lib/main.dart errors 不适用于 main.dart 配置 flutter android 工作室模拟器错误 - not applicable for main.dart configuration flutter android studio emulator error 不适用于main.dart配置 - Not applicable for the main.dart configuration 归档 flutter 应用程序时在项目中找不到 main.dart - main.dart is not found in project when archiving flutter app Flutter 在 main.dart 文件中添加提供程序的更好方法 - Flutter Better way to add Providers in main.dart file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM