当前位置:网站首页>【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…。
边栏推荐
- FTP protocol
- From SiCp to LISP video replay
- Pandora IOT development board learning (RT thread) - Experiment 17 esp8266 experiment (learning notes)
- Bugku login2
- Operating system migration practice: deploying MySQL database on openeuler
- 2022年最新西藏建筑施工架子工(建筑特种作业)模拟考试试题及答案
- Taishan Office Technology Lecture: the zoom ratio of word is slightly different from the display
- 国元期货网上开户安全吗?开户办理流程是怎样的?
- 【万字长文】使用 LSM-Tree 思想基于.Net 6.0 C# 实现 KV 数据库(案例版)
- The process and harvest of developing browser plug-ins with clojurescript
猜你喜欢
![[BJDCTF2020]Easy MD5](/img/6a/61a4b5624c33f1f334bea344cfa2c8.png)
[BJDCTF2020]Easy MD5

Re7: reading papers fla/mlac learning to predict charges for critical cases with legal basis

工作流引擎在vivo营销自动化中的应用实践

测试用例千万不能随便,记录由一个测试用例异常引起的思考

PAT甲级 1049 Counting Ones

FTP协议

PAT甲级 1044 Shopping in Mars

Acl-ijcai-sigir top conference paper report meeting (AIS 2022) Note 3: dialogue and generation

FTP protocol

面试时候常说的复杂度到底是什么?
随机推荐
微信小程序---网络数据请求
Clojure Web Development -- ring user guide
Implementation of SAP ABAP daemon
Octree establishes map and realizes path planning and navigation
量化交易之数字货币篇 - 通过时间戳与方向来合并逐笔成交数据(大单合并)
Google Earth Engine——MERRA-2 M2T1NXAER:1980-2022年气溶胶逐日数据集
Google Earth engine - merra-2 m2t1nxaer: aerosol daily data set from 1980 to 2022
vlang捣鼓之路
2021年软件测试工具趋势
vscode批量删除
Pat class a 1047 student list for course
Summary of key knowledge of C language
[physical simulation] the principle and practice of the simplest shape matching
How to test the circle of friends (mind map)
Linux Installation mysql8.0.29 detailed tutorial
Modify the password of the root user of MySQL database
Google Earth Engine——MERRA-2 M2T1NXSLV:1980-至今全球压力、温度、风等数据集
Build resume editor based on Nocode
Some cutting-edge research work sharing of SAP ABAP NetWeaver containerization
初识OpenGL (2)编译着色器