问题描述
我正在尝试设置带有波动的Android风格.
I am trying to set up Android flavors with flutter.
我有两个入口点.
lib/main_prod.dart
lib/main_dev.dart
我还在我的gradle文件中添加了以下内容
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"
}
}
现在,我正在尝试生成两个单独的APK,可以将其发布到Google Play商店.
Now I am trying to generate two separate apk which I can use to publish to the Google Play Store.
我继续使用Android Studio并尝试生成这些.
I go on Android Studio and try generate these.
但是我收到此错误.
Android Studio仍在尝试查找main.dart文件,但是,对于我的两种风格,它们分别是main_prod.dart和main_dev.dart.我如何告诉Android Studio根据试图获取apk文件的风格来寻找合适的主文件.
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.
推荐答案
要针对每种口味构建apk或appBundle(发布到Playstore),您可以使用命令(推荐)而不是使用android studio.
To build apk or appBundle(to publish to the playstore) for each flavor you can use the commands(recommended) instead of using android studio.
对于 prod
,您可以使用:
APK
flutter build apk --flavor prod -t lib/main_prod.dart
AppBundle
AppBundle
flutter build appbundle --flavor prod -t lib/main_prod.dart
以及 dev
APK
flutter build apk --flavor dev -t lib/main_dev.dart
AppBundle
AppBundle
flutter build appbundle --flavor dev -t lib/main_dev.dart
这篇关于Flutter Android风格生成APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!