I am trying to set up Android flavors with flutter.
I have two entry points.
lib/main_prod.dart
lib/main_dev.dart
I have also added the following to my gradle file
flavorDimensions "version"
productFlavors {
prod {
dimension "version"
applicationIdSuffix ".prod"
}
dev {
dimension "version"
applicationIdSuffix ".dev"
versionNameSuffix " Dev"
}
}
Now I am trying to generate two separate apk which I can use to publish to the Google Play Store.
I go on Android Studio and try generate these.
However I get this error.
Android Studio is still trying to look for the main.dart file, however, for my two flavors they are main_prod.dart and main_dev.dart. How do I tell Android Studio to look for the approperiate main file depending on the flavor im trying to get the apk file for.
To build apk or appbundle(to publish to the playstore) for each flavor you can use the commands(recommended) instead of using android studio.
For prod
you can use:
APK
flutter build apk --flavor prod -t lib/main_prod.dart
App Bundle
flutter build appbundle --flavor prod -t lib/main_prod.dart
and for dev
APK
flutter build apk --flavor dev -t lib/main_dev.dart
App Bundle
flutter build appbundle --flavor dev -t lib/main_dev.dart