flutter-学习之发布安卓包APK

001 设置图标:在链接自动生成图标网站就可以快速生成用得到的图标,下载之后全选复制在项目替换flutter自动生成的图标

002 生成密钥库文件.jsk结尾 记住密码和存储密码 

003 新建文件key.properties 配置如下信息

keyAlias = key

keyPassword = 密码

storeFile = 密钥库文件的绝对路径

storePassword = 密码

004 配置签名文件 build.gradle

在android {

}

之前定义key.properties的信息

def keystoreProperties = new Properties()

def keystorePropertiesFile = rootProject.file('key.properties')

if (keystorePropertiesFile.exists()) {

keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

}

在defaultConfig{}中配置//选择要添加的对应 cpu 类型的 .so 库。

ndk {

//选择要添加的对应 cpu 类型的 .so 库。

abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a'

}

配置签名

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

    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.release
        }
    }

005 在VSCode终端中输入命令打包

flutter build apk --no-shrink 就可以打包 这样是不会进行压缩打包的 就是为了加快速度

过程如下

maochengfang@maochenangdeMBP DragglableDemo % flutter build apk --no-shrink
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the
APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64
        --split-per-abi
        Learn more on:
        https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...                                
Running Gradle task 'assembleRelease'... Done                      48.9s
✓ Built build/app/outputs/flutter-apk/app-release.apk (16.2MB).

006 在android/build/app/outputs/flutter-apk/文件下可以看到我们打包的release版本

007 就可以在手机上安装了

参考资料:

https://flutter.cn/docs/deployment/android

https://icon.wuruihong.com/icon?utm_source=dNqZtoOV#/android

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值