当前位置:网站首页>App signature in flutter
App signature in flutter
2022-08-02 14:55:00 【shinechow】
First, create a keystore
1. Enter the command first:
keytool -genkey -v -keystore ./key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
2. Enter relevant parameters as prompted, as shown in the following figure 
Second, refer to the keystore (
1. Create a file named
that contains a reference to the keystore:
storePassword=The password entered in the key.jks file created in the first stepkeyPassword=password entered in the key.jks file created in the first stepkeyAlias=key //.jks file name, here we created key.jks, so it is keystoreFile=The storage path of the key.jks file created in the first step, such as: C:/Users//key.jks
Note:
- Keep the file private and do not put it in public source control; The path in
storeFile
is a relative path starting with
, so it is recommended to use an absolute path in order to prevent unnecessary errorsli>/android/app/
2. Configure the signature in gradle
Configure signing for your app by editing the
file
(1)Adddef 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']}}(2) Modify buildTypesbuildTypes {release {signingConfig signingConfigs.releasendk{ // This part must be added, otherwise it may cause the successfully compiled release package to crash on the real machineabiFilters "armeabi-v7a"}}debug {ndk {//It should be added here, otherwise there will be problems with the debug package. The last three are optional. It is recommended to add x86 or some simulators will report errors.abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86"}}}
Note:
Therelease
package may crash in the real machine because the so file of l
causing "compatibility" issues on ibflutter
of arm64
was not introduced in the package.arm64
mobile phones.
The main problem is that the so library is referenced. The arm64cpu architecture is backward compatible, that is, the cpu of the arm64
architecture can use the arm32 .so
file.The real reason for the problem is when we reference the so library (the so library is referenced in the referenced third-party library).
Three, turn on obfuscation
Flutter does not enable Android obfuscation by default.
If you use a third-party Java or Android library, maybe you want to reduce the size of the apk file or prevent the code from being reversed.
Configuration Obfuscation
Create a /android/app/proguard-rules.pro
file and add the following rules:
#Flutter Wrapper-keep class io.flutter.app.** { *; }-keep class io.flutter.plugin.** { *; }-keep class io.flutter.util.** { *; }-keep class io.flutter.view.** { *; }-keep class io.flutter.** { *; }-keep class io.flutter.plugins.** { *; }Copy code
Note: The above configuration only confuses the Flutter engine library, any other library (such as Firebase) needs to add the corresponding rules.
Enable obfuscation/compression
Open the /android/app/build.gradle
file and locate the buildTypes
block.
Set minifyEnabled
and useProguard
to true
in the release
configuration, and then point the obfuscated file to the previous stepcreated file.
android {...buildTypes {release {signingConfig signingConfigs.releaseminifyEnabled trueuseProguard trueproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}}
Fourth, build a release APK
If you complete the signing steps, the APK will be signed.
Using the command line:
cd
- Run
flutter build apk
(flutter build
will include the--release
option by default).
The packaged release APK is located at
.
5. Install the release APK on the device
Follow the steps below to install the APK built in the previous step on a connected Android device
- Connect your Android device to your computer with USB
- Run
cd
. - Run
flutter install
.
边栏推荐
- VS Code无法安装插件之Unable to install because, the extension '' compatible with current version
- PostgreSQL 性能谜题
- Spark_Core
- C语言日记 5、7setprecision()问题
- 加减法运算及其溢出处理
- MySQL知识总结 (九) 用户与用户权限管理
- Cannot figure out how to save this field into database. You can consider adding a type converter for
- static关键字3种作用,简单粗暴对比,好理解
- 我的第一篇博客
- 芝诺悖论的理解
猜你喜欢
随机推荐
Kubernetes架构和组件
Tornado framework routing system introduction and (IOloop.current().start()) start source code analysis
二进制乘法运算
无人驾驶综述:摘要
Ehcache基础学习
MySQL知识总结 (一) 数据类型
It is not allowed to subscribe with a(n) xxx multiple times.Please create a fresh instance of xxx
C语言日记 7 输入/输出格式控制
【c】小游戏---扫雷雏形
verilog学习|《Verilog数字系统设计教程》夏宇闻 第三版思考题答案(第十一章)
MongoDB安装流程心得:
ConstraintLayout from entry to abandonment
vscode compiles the keil project and burns the program
C语言初级—用一角,两角,五角和一元组成3.5元有多少种组合方法
VS2017中安装visual assist X插件
MySQL 8.0 新特性
AAPT: error: duplicate value for resource ‘attr/xxx‘ with config ‘‘, file failed to compile.
The Handler you really understand?
LLVM系列第二十六章:理解LLVMContext
宝塔搭建PHP自适应懒人网址导航源码实测