美文网首页
flutter学习笔记(一)

flutter学习笔记(一)

作者: AJI大侠 | 来源:发表于2018-07-29 12:39 被阅读38次

    flutter学习笔记(一)

    Android的打包过程

    1. 创建keystore证书
      如果您已经创建过证书则可以跳过这一步。若要创建新的证书,请在命令行中执行如下命令:

    keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

    1. 在应用中引用keystore证书

    创建一个名为<app dir>/android/key.properties的文件,其中包含对密钥库的引用:

    storePassword=<上一步中输入的 store 密码>
    keyPassword=<上一步中输入的 key 密码>
    keyAlias=key
    storeFile=<keystore 文件的位置, 例如: /Users/<user name>/key.jks>

    1. 在 gradle 中配置签名选项

    通过编辑<app dir>/android/app/build.gradle文件为您的应用配置签名

    1.找到android {,然后替换为您包含证书引用的配置文件:

    def keystorePropertiesFile = rootProject.file("key.properties")
    def keystoreProperties = new Properties()
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

    android {

    2.替换:

    buildTypes {
    release {
    // TODO: Add your own signing config for the release build.
    // Signing with the debug keys for now, so flutter run --release works.
    signingConfig signingConfigs.debug
    }
    }

    为如下内容:

    signingConfigs {
    release {
    keyAlias keystoreProperties['keyAlias']
    keyPassword keystoreProperties['keyPassword']
    storeFile file(keystoreProperties['storeFile'])
    storePassword keystoreProperties['storePassword']
    }
    }
    buildTypes {
    release {
    signingConfig signingConfigs.release
    }
    }

    1. 构建 release 版应用

    在命令行使用:

    cd <app dir> (用您应用工程的根目录替换<app dir> )。

    运行flutter build apk (flutter build命令默认使用--release)。

    您应用的release版本的APK会生成在<app dir>/build/app/outputs/apk/app-release.apk

    1. 将 release 版本的 APK 安装到设备上

    使用命令行:

    • 用USB您的Android设备连接到您的电脑
    • cd <app dir> .
    • 运行 flutter install .

    相关文章

      网友评论

          本文标题:flutter学习笔记(一)

          本文链接:https://www.haomeiwen.com/subject/llxnuftx.html