1,设置安卓签名
xml
keytool -genkey -alias <your_alias_name> -keypass <your_pwd> -storepass <your_pwd> -keyalg RSA -keysize 2048 -validity 36500 -storetype pkcs12 -keystore <your_path>.jks
2, 设置 android/app/build.gradle
通过配置 productFlavors,可以配置不同环境的包名和App名字等
java
defaultConfig {
applicationId "com.ski.pollka.snow.dev"
// Android 6.0 (App Links minimum support Android 6.0)
minSdkVersion 23
// Android 12+,Google play requirements
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
flavorDimensions "env"
productFlavors {
dev {
dimension "env"
applicationId "com.ski.pollka.snow.dev"
resValue "string", "app_name", "Pollka Snow Dev"
signingConfig signingConfigs.pollkaSnow
}
qa {
dimension "env"
applicationId "com.ski.pollka.snow.qa"
resValue "string", "app_name", "Pollka Snow Test"
signingConfig signingConfigs.pollkaSnow
}
product {
dimension "env"
applicationId "com.ski.pollka.snow.product"
resValue "string", "app_name", "Pollka Snow"
signingConfig signingConfigs.pollkaSnow
}
}
signingConfigs {
pollkaSnow {
storeFile file('<name>.jks')
storePassword "<storePassword>"
keyAlias "<keyAlias>"
keyPassword "<keyPassword>"
}
}
buildTypes {
debug {
// Signature needs to be set to use App link
// If set to null, channel signature will be used, if not set, system default signature will be used
signingConfig null
}
profile {
signingConfig null
}
release {
ndk{
abiFilters 'armeabi-v7a','arm64-v8a'
}
signingConfig null
debuggable false
// https://developer.android.com/studio/build/shrink-code?utm_source=android-studio#shrink-resources
zipAlignEnabled true
minifyEnabled true
shrinkResources true
}
}
3,修改 android/app/scr/main/AndroidManifest.xml, 配置安卓不同环境的App名称
ini
android:label="pollka_snow"
->
android:label="@string/app_name"
4,运行结果
VSCode 依次运行安装 pollka-snow-dev/qa/product App