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

相关推荐
Zender Han1 小时前
Flutter自定义矩形进度条实现详解
android·flutter·ios
hello world smile1 小时前
关于Flutter空安全升级方案整理
flutter·移动端
君蓦16 小时前
Flutter 本地存储与数据库的使用和优化
flutter
problc1 天前
Flutter中文字体设置指南:打造个性化的应用体验
android·javascript·flutter
lqj_本人1 天前
鸿蒙next选择 Flutter 开发跨平台应用的原因
flutter·华为·harmonyos
lqj_本人2 天前
Flutter&鸿蒙next 状态管理框架对比分析
flutter·华为·harmonyos
起司锅仔2 天前
Flutter启动流程(2)
flutter
hello world smile2 天前
最全的Flutter中pubspec.yaml及其yaml 语法的使用说明
android·前端·javascript·flutter·dart·yaml·pubspec.yaml
lqj_本人2 天前
Flutter 的 Widget 概述与常用 Widgets 与鸿蒙 Next 的对比
flutter·harmonyos