Flutter如何创建一个企业级项目-Android篇(二)

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

相关推荐
江上清风山间明月6 小时前
flutter bottomSheet 控件详解
android·flutter·底部导航·bottomsheet
yuanlaile1 天前
纯Dart Flutter库适配HarmonyOS
flutter·华为·harmonyos·flutter开发鸿蒙·harmonyos教程
yuanlaile1 天前
Flutter开发HarmonyOS 鸿蒙App的好处、能力以及把Flutter项目打包成鸿蒙应用
flutter·华为·harmonyos·flutter开发鸿蒙
zacksleo1 天前
鸿蒙原生开发手记:04-一个完整元服务案例
flutter
jcLee952 天前
Flutter/Dart:使用日志模块Logger Easier
flutter·log4j·dart·logger
tmacfrank2 天前
Flutter 异步编程简述
flutter
tmacfrank2 天前
Flutter 基础知识总结
flutter
叫我菜菜就好2 天前
【Flutter_Web】Flutter编译Web第三篇(网络请求篇):dio如何改造方法,变成web之后数据如何处理
前端·网络·flutter
AiFlutter2 天前
Flutter-底部分享弹窗(showModalBottomSheet)
java·前端·flutter
m0_748247803 天前
Flutter Intl包使用指南:实现国际化和本地化
前端·javascript·flutter