手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >ANDROID应用程序的混淆打包分享
ANDROID应用程序的混淆打包分享
摘要:android应用程序的混淆打包1.在工程文件project.properties中加入下proguard.config=proguard....

android应用程序的混淆打包

1 . 在工程文件project.properties中加入下proguard.config=proguard.cfg , 如下所示:

target=android-8

proguard.config=proguard.cfg

Eclipse会通过此配置在工程目录生成proguard.cfg文件

2 . 生成keystore (如已有可直接利用)

按照下面的命令行 在D:Program FilesJavajdk1.6.0_07bin>目录下,输入keytool -genkey -alias android.keystore -keyalg RSA -validity 100000 -keystore android.keystore

参数意义:-validity主要是证书的有效期,写100000天;空格,退格键 都算密码。

命令执行后会在D:Program FilesJavajdk1.6.0_07bin>目录下生成 android.keystore文件。

3. 在Eclipce的操作

File -> Export -> Export Android Application -> Select project -> Using the existing keystore , and input password -> select the destination APK file

经过混淆后的源代码,原先的类名和方法名会被类似a,b,c。。。的字符所替换,混淆的原理其实也就是类名和方法名的映射。

但4大组件并没有混淆(所有在清单文件定义的组件不能被混淆),因为系统需要通过清单文件来查找和运行应用程序。

proguard.cfg 文件代码解读

-optimizationpasses 5 ->设置混淆的压缩比率 0 ~ 7

-dontusemixedcaseclassnames -> Aa aA

-dontskipnonpubliclibraryclasses ->如果应用程序引入的有jar包,并且想混淆jar包里面的class

-dontpreverify

-verbose ->混淆后生产映射文件 map 类名->转化后类名的映射

-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* ->混淆采用的算法.

-keep public class * extends android.app.Activity ->所有activity的子类不要去混淆

-keep public class * extends android.app.Application

-keep public class * extends android.app.Service

-keep public class * extends android.content.BroadcastReceiver

-keep public class * extends android.content.ContentProvider

-keep public class * extends android.app.backup.BackupAgentHelper

-keep public class * extends android.preference.Preference

-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {

native <methods>; -> 所有native的方法不能去混淆.

}

-keepclasseswithmembers class * {

public <init>(android.content.Context, android.util.AttributeSet);

-->某些构造方法不能去混淆

}

-keepclasseswithmembers class * {

public <init>(android.content.Context, android.util.AttributeSet, int);

}

-keepclassmembers class * extends android.app.Activity {

public void *(android.view.View);

}

-keepclassmembers enum * { -> 枚举类不能去混淆.

public static **[] values();

public static ** valueOf(java.lang.String);

}

-keep class * implements android.os.Parcelable { -> aidl文件不能去混淆.

public static final android.os.Parcelable$Creator *;

}

【ANDROID应用程序的混淆打包分享】相关文章:

Android应用程序的调试

Android应用程序签名步骤及相关知识介绍

浅谈AnDroidDraw+DroidDraw实现Android程序UI设计的分析说明

为Android应用增加渠道信息 自动化不同渠道的打包过程的使用详解

Android 用SQLite实现事务的方法

Android应用开发中对Bitmap的内存优化

Android 完全退出应用程序的解决方法

Android 简单的照相机程序的实例代码

android 为应用程序创建桌面快捷方式技巧分享

Android应用开发中模拟按下HOME键的效果(实现代码)

精品推荐
分类导航