当前位置:网站首页>【Flutter -- 进阶】打包
【Flutter -- 进阶】打包
2022-07-26 16:08:00 【Kevin-Dev】

1. 生成key
编写完应用后,最后就是打包了,因为我是用 Android studio 开发的,所以直接在 Terminal 输入:
keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 100000 -alias key
这里记住 -alias key key是别名,可以自己随意更改,弹出:
输入密钥库口令:
再次输入新口令:
您的名字与姓氏是什么?
[Unknown]: knight
您的组织单位名称是什么?
[Unknown]: knight
您的组织名称是什么?
[Unknown]: knight
您所在的城市或区域名称是什么?
[Unknown]: knight
您所在的省/市/自治区名称是什么?
[Unknown]: knight
该单位的双字母国家/地区代码是什么?
[Unknown]: C
CN=knight, OU=knight, O=knight, L=knight, ST=knight, C=C是否正确?
[否]: Y
正在为以下对象生成 2,048 位RSA密钥对和自签名证书 (SHA256withRSA) (有效期为 100,000 天):
CN=knight, OU=knight, O=knight, L=knight, ST=knight, C=C
[正在存储/Users/luguian/key.jks] -->生成对应的签名文件
我把它复制到android目录下。
2. 创建key.properties
在android目录下创建一个key.properties:
3. 更改build.gradle

----->增加
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
----->
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutterdemo"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
----->增加
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
// proguard文件是混淆
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
------>增加
}
4.添加混淆文件
默认情况下,Flutter不会混淆或缩小Android主机。如果您打算使用第三方Java或Android库,您可能希望减小APK的大小或保护该代码免受逆向工程,那就在在android/app/下添加proguard-rules.pro:
最后在项目根目录执行:
flutter build apk
Initializing gradle... 0.6s
Resolving dependencies... 1.3s
Gradle task 'assembleRelease'...
Gradle task 'assembleRelease'... Done 7.2s
Built build/app/outputs/apk/release/app-release.apk (15.8MB).
最后输出在build-app-release下:
这样就成功了。
ios怎么打包,具体请查看 flutter.dev/docs/deploy…。
边栏推荐
- [ten thousand words long text] Based on LSM tree thought Net 6.0 C # realize kV database (case version)
- “核弹级” Log4j 漏洞仍普遍存在,并造成持续影响
- 绘制漂亮的中学操场轮廓,生成带经纬度数据
- 研发效能的道与术 - 道篇
- Activity之onCreate、onRestoreInstanceState恢复数据的区别
- zabbix 6.2.0部署
- 《硅谷之谜》读后感
- Octree establishes map and realizes path planning and navigation
- Acl-ijcai-sigir top conference paper report meeting (AIS 2022) Note 3: dialogue and generation
- PAT甲级 1049 Counting Ones
猜你喜欢

PAT甲级 1044 Shopping in Mars

Implementation of SAP ABAP daemon

Bugku login2

【万字长文】使用 LSM-Tree 思想基于.Net 6.0 C# 实现 KV 数据库(案例版)
![[ten thousand words long text] Based on LSM tree thought Net 6.0 C # realize kV database (case version)](/img/84/640de0bf779cd45498204909be56d1.png)
[ten thousand words long text] Based on LSM tree thought Net 6.0 C # realize kV database (case version)

Comprehensively design an oppe homepage -- the design of the top and head

Pat grade a 1046 shortest distance

Test cases should never be used casually, recording the thinking caused by the exception of a test case

2022 latest Tibet Construction scaffolder (construction special operation) simulation exam questions and answers

The "nuclear bomb level" log4j vulnerability is still widespread and has a continuing impact
随机推荐
想让照片中的云飘起来?视频编辑服务一键动效3步就能实现
C语言重点知识总结
辨析 Ruby 中的 Method 与 Proc
使用 ClojureScript 开发浏览器插件的过程与收获
Trends in software testing tools in 2021
剑指offer专项突击版第11天
What is GPIO and what is its use
Bugku login2
Pat grade a 1048 find coins
绘制漂亮的中学操场轮廓,生成带经纬度数据
From SiCp to LISP video replay
Specific practice cases of "card note taking method" in Siyuan
Re8:读论文 Hier-SPCNet: A Legal Statute Hierarchy-based Heterogeneous Network for Computing Legal Case
面试时候常说的复杂度到底是什么?
综合设计一个OPPE主页--明星机型的设计
[physical simulation] the principle and practice of the simplest shape matching
Which book is the "the Nine Yin Manual" in the field of programming
How to configure tke cluster node Max pod
微信小程序---网络数据请求
初识OpenGL (4)链接着色器