我正在使用 Flutter(1.17.4 版)开发 Android 并配置multi Flavors
运行多环境。
我的源代码有 3 个环境:(dev
开发)、uat
(QC)、prod
(生产)。
Source
: https://github.com/huubao2309/demo_multi_flavors
我的multiFlavors.gradle
文件(/android/app/multiFlavors.gradle
):
android {
flavorDimensions "app"
productFlavors {
prod {
dimension "app"
applicationIdSuffix ".prod"
versionNameSuffix "-prod"
}
dev {
dimension "app"
applicationIdSuffix ".dev"
versionNameSuffix "-dev"
}
uat {
dimension "app"
applicationIdSuffix ".uat"
versionNameSuffix "-uat"
}
}
}
每次,我都会构建应用程序以使用终端发布:
flutter build apk --flavor uat -t lib/main-uat.dart
文件 .apk 已创建,但终端抛出异常:
Gradle build failed to produce an .apk file. It's likely that this file was generated under D:\demo_multi_flavors\build, but the tool couldn't find it.
我在模式下运行时也遇到了这个问题debug
,但是在Android Studio(4.0版)上,我添加了 config build flavor
,问题得到解决:
如何解决发布模式的问题?