create_flutter_provider_app icon indicating copy to clipboard operation
create_flutter_provider_app copied to clipboard

Gradle build failed to produce

Open seskiramadhan opened this issue 4 years ago • 7 comments

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

seskiramadhan avatar Aug 20 '20 18:08 seskiramadhan

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

rainerlonau avatar Sep 01 '20 14:09 rainerlonau

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.

KenAragorn avatar Sep 08 '20 07:09 KenAragorn

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 avatar Sep 27 '20 05:09 kirkcharlesniv

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"
            ]
        }

kirkcharlesniv avatar Sep 27 '20 05:09 kirkcharlesniv

Hi @kirkcharlesniv , @rainerlonau ,

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

I will need to update the README on this.

KenAragorn avatar Sep 28 '20 06:09 KenAragorn

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 avatar Sep 17 '21 08:09 arturjnt

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"
            ]
        }
    ]
}

arturjnt avatar Sep 27 '21 13:09 arturjnt