Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle build failed to produce #5

Open
seskiramadhan opened this issue Aug 20, 2020 · 7 comments
Open

Gradle build failed to produce #5

seskiramadhan opened this issue Aug 20, 2020 · 7 comments

Comments

@seskiramadhan
Copy link

Hi Ken,

just wanna thank you, this project is amazing

I just wanna share my problem with this project

I got this error

Exception: Gradle build failed to produce an .apk file. It's likely that this file was generated under
/home/myusername/Git/create_flutter_provider_app/build, but the tool couldn't find it.

And i do solve it with creating new flutter project then copy build.grade in app folder, and paste it to your amazing template

@rainerlonau
Copy link

I had the same error. For me it was because I clicked the default run main.dart button to start the app.
I adjusted the run configuration for "dev" and "prod" as described in "Extras 2: Config Android Studio to run Flutter Flavor" here https://medium.com/@vo9312/flutter-series-part-1-flutter-flavors-setup-bb6aba1586ac

@KenAragorn
Copy link
Owner

Hi @FunGuardian , thanks for the sharing. Is the exception occur everytime when you build or occasionally few times? The reason I asked this is because, I encounter before and although the exception was thrown, but the .apk file is successfully build in the project build output folder.

@kirkcharlesniv
Copy link

This only occurs when not running the specified commands from the documentation:

flutter run --flavor prod -t lib/main_prod.dart or flutter run --flavor dev -t lib/main.dart

@kirkcharlesniv
Copy link

If you are using VS Code, add these on your launch.json -> configurations

        {
            "name": "Dev",
            "request": "launch",
            "type": "dart",
            "args": [
                "--flavor",
                "dev",
                "-t",
                "lib/main.dart"
            ]
        },
        {
            "name": "Prod",
            "request": "launch",
            "type": "dart",
            "args": [
                "--flavor",
                "prod",
                "-t",
                "lib/main_prod.dart"
            ]
        }

@KenAragorn
Copy link
Owner

Hi @kirkcharlesniv , @rainerlonau ,

Thanks a lot for the comment and helps. This helps a lot.

I will need to update the README on this.

@arturjnt
Copy link

arturjnt commented Sep 17, 2021

Hello @KenAragorn , if I might make a suggestion, on the README.md step 10

Instead of:

Done. Try launch the app using emulator or your preferred physical test device. For first time user, you need to create a new account from the app.

maybe a more accurate documentation would be:

Done. Try launch the app using emulator or your preferred physical test device by using flutter run --flavor dev -t lib/main.dart. For first time users, you need to create a new account from the app.

I'm only suggesting this because I too got stuck here for a few minutes until I realized what was wrong, and only now found this issue that clarifies the situation.

@arturjnt
Copy link

arturjnt commented Sep 27, 2021

If you are using VS Code, add these on your launch.json -> configurations

        {
            "name": "Dev",
            "request": "launch",
            "type": "dart",
            "args": [
                "--flavor",
                "dev",
                "-t",
                "lib/main.dart"
            ]
        },
        {
            "name": "Prod",
            "request": "launch",
            "type": "dart",
            "args": [
                "--flavor",
                "prod",
                "-t",
                "lib/main_prod.dart"
            ]
        }

Also, this configuration worked better for me (file .vscode/launch.json)

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Dev",
            "request": "launch",
            "type": "dart",
            "flutterMode": "debug",
            "program": "lib/main.dart",
            "args": [
                "--flavor",
                "dev"
            ]
        },
        {
            "name": "Prod",
            "request": "launch",
            "type": "dart",
            "flutterMode": "release",
            "program": "lib/main_prod.dart",
            "args": [
                "--flavor",
                "prod"
            ]
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants