Android proguard代码混淆
Google在2.3之后tools中就添加了自带的混淆器android-sdk-windows\tools\proguard
使用步骤如下:
一、在新建2.3项目的时候会自动生成proguard.cfg的文件
(如果你是2.3之前的版本,需要自己拷贝此文件到工程目录下)
文件中代码已经生成,如下:
-optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify -verbose -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* -keep public class * extends android.app.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>; } -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 { public static final android.os.Parcelable$Creator *; }
二、在project.properties(default.properties)中添加一行命令,如下
# This file is automatically generated by Android Tools. # Do not modify this file -- YOUR CHANGES WILL BE ERASED! # # This file must be checked in Version Control Systems. # # To customize properties used by the Ant build system use, # "ant.properties", and override values to adapt the script to your # project structure. # Project target. target=android-9 proguard.config=proguard.cfg
三、重新生成apk
这里需要注意的是,如果只是clean后再bin下面生成的apk,会发现混淆没有起作用,还是和以前一样
这里我使用 右键点击工程->>Android Tools->>Export Signed Application Package..
上述步骤是对程序进行签名发布,在这时会对代码进行混淆。
如果混淆遇到错误,请首先检查你的工程路径是不是存在空格。
然后反编译出来就是a b c d之类的了
相关推荐
shinecjj 2015-06-13
learningITwell 2011-12-30
易辰Android 2011-11-13
易辰Android 2012-04-20
RickyLee 2015-01-02
yuyu00 2019-06-29
知其然知其所以然 2012-08-10
mlsnatalie 2018-03-15
蓝天梦 2015-09-06
tdltdltdl 2015-08-14
mscn 2015-06-13
wolfoxkao 2013-10-28
NatureDay 2013-07-21
xuguolibeyondboy 2013-05-09
dingguagua 2013-03-17
GoAheadY 2012-12-19
kangtingting0 2012-08-20
newfarhui 2012-07-30
huzhenv 2012-07-21
xuguolibeyondboy 2012-07-11
scott0 2012-07-07