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
in my case I have a multi flavor app like this:
update 04/15/2021:
{
// 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
]
}
]
Another way:
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"
}
}
}
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
and I solved my error and built the .apk
Added the flavor name in Build name
from Edit Configurations
and it worked!
Ok, I found that it's args
in launch.json
if you use vscode