flutter android 混淆

原文链接:https://www.jianshu.com/p/dfa518270c9a

第一、Android端打包

签名步骤:

1.首先找到Studio =====> Build ====>Generate Signed Bundle / APK

image

2.输入key Store 存放地址,设置密码,建议存放在项目,

image

3.如图所示:

image

标注1:是存放在项目app下面的密钥

标注2:新建file文件key.properties 存放的是密码,密钥,别名

storePassword=111111

keyPassword=111111

keyAlias=flutter

storeFile=../flutter_key_store

标注3:新建proguard-rules.pro存放的是 代码混淆的配置

注意:这个配置要放在/android/app/proguard-rules.pro

-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.** { *; }

在 build.gradle 中进行配置密钥和代码混淆

在build.gradle android 上面进行配置

def keystoreProperties =new Properties()

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

if (keystorePropertiesFile.exists()) {

keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

}

在build.gradle android 里面进行配置

signingConfigs{

release{

    //设置密钥配置

    keyAlias keystoreProperties['keyAlias']

    keyPassword keystoreProperties['keyPassword']

    storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) :null

    storePassword keystoreProperties['storePassword']

}

}

buildTypes{

release{

    signingConfig signingConfigs.release

   //代码混淆需要添加的

    minifyEnabledtrue  //资源压缩设置

    useProguardtrue    //代码压缩设置

   //读取代码压缩配置文件

    proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'

}

}

4.直接打包APK

image
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。