zoukankan      html  css  js  c++  java
  • Flutter设置APP版本与构建版本

    csdn 

    打包

    android

    https://blog.csdn.net/sundaysme/article/details/106264735

    https://blog.csdn.net/K_Hello/article/details/104795537?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-4.add_param_isCf&depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-4.add_param_isCf 

    简述

    https://www.jianshu.com/p/3011c694d037

    ios

    简单命令

    flutter clean

    rm -rf ios/Flutter/App.framework

    先在项目目录下运行

    flutter build ios --release
    

    再到xcode下进行打包

    如果不进行build命令,则在xcode下会报错:

    flutter Could not find an option named "track-widget-creation".
    

    具体打包方法:
    https://github.com/bingoogolapple/bingoogolapple.github.io/issues/46

    当一个纯Flutter APP开发完成,我们要打包发布到App Store和各大安卓市场,这时候我们需要设置APP的版本号。

      如果我们在使用原生iOS或者Android开发的时,我们会在info.plist中设置versionbuild或是在build.gradle中设置versionNameversionCode,他们分别表示APP的版本和构建版本。

      但是我们在使用Flutter管理APP版本时,打开pubspec.yaml只看到一个version字段。这时候我们应该怎么设置APP的versionbuild呢?

      我们在pub上随便找一个Flutter的组件,例如官方的camera,我们可以看到截止目前为止最新的版本为:camera: ^0.5.2+1。看到这里,我想大家都明白了,Dart采用的是加号式的版本描述方式,+前面是版本号,+后面是当前版本的build号。所以我们设置APP的版本号和build次数,在这里设置即可,例如:version: 1.2.0+1

      当我们新建一个Flutter工程的时候,我们分别使用Xcode和Android Studio打开iOS和Android的工程可以看到,iOS中的 version和 build的值分别为FLUTTER_BUILD_NAME 和 FLUTTER_BUILD_NUMBER

        <!-- version -->
        <key>CFBundleShortVersionString</key>
        <string>$(FLUTTER_BUILD_NAME)</string>
        <key>CFBundleSignature</key>
        
        <!-- build -->
        <key>CFBundleVersion</key>
        <string>$(FLUTTER_BUILD_NUMBER)</string>
        <key>LSApplicationCategoryType</key>
    

    同样我们打开Android工程可以看到有如下定义:

        def flutterVersionCode  =  localProperties.getProperty('flutter.versionCode')
        
        if (flutterVersionCode == null) {
            flutterVersionCode = '1'
        }
    
        def flutterVersionName = localProperties.getProperty('flutter.versionName')
        if (flutterVersionName == null) {
            flutterVersionName = '1.0.0'
        }
    
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    

      事实上,Flutter在编译的时候会生成ios/Flutter/Generated.xcconfigandroid/local.properties文件。这两个文件由Flutter编译自动生成,不可更改。记录了包含SDK路径或者文件路径,版本信息,环境配置(release/debug)等信息。原生工程获取版本信息的变量就定义在这两个文件里面。



    作者:readonly__
    链接:https://www.jianshu.com/p/3011c694d037
    来源:简书
    著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

    https://segmentfault.com/a/1190000013672885

    大致是这几个步骤:

    1.命令行生成key.jks文件;

    2.在flutter项目中,android文件夹下进行相关配置,需配置的地方有:

    --新建key.properyties文件,配置

    storePassword=秘钥库密码
    keyPassword=秘钥密码
    keyAlias=key
    storeFile=秘钥完整路径

    --app/build.gradle文件中

    def keystorePropertiesFile = rootProject.file("key.properties")
    def keystoreProperties = new Properties()
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
    
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
    

    3.生成apk:flutter build apk

    检测设备

    adb devices  

    4.安装apk:flutter install

  • 相关阅读:
    Spark SQL ---一般有用
    idea快捷键
    04.Scala编程实战 ---没看
    03.Scala高级特性 ---没看
    02.Actor编程 ---没看
    01.Scala编程基础 ---没看
    附6、Storm面试题目答疑 ---一般有用
    扩展运算符
    ES6新增数组方法(部分)
    for of 循环
  • 原文地址:https://www.cnblogs.com/sundaysandroid/p/13494911.html
Copyright © 2011-2022 走看看