apk混淆签名打包
写好混淆配置文件,再对apk进行签名打包即可得到混淆后的apk包
签名打包参考:http://jojol-zhou.iteye.com/blog/719428
我常用的混淆配置文件
-optimizationpasses5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations!code/simplification/arithmetic,!field/*,!class/merging/*
-keeppublicclass*extendsandroid.app.Activity
-keeppublicclass*extendsandroid.app.Application
-keeppublicclass*extendsandroid.app.Service
-keeppublicclass*extendsandroid.content.BroadcastReceiver
-keeppublicclass*extendsandroid.content.ContentProvider
-keeppublicclass*extendsandroid.app.backup.BackupAgentHelper
-keeppublicclass*extendsandroid.preference.Preference
-keeppublicclasscom.android.vending.licensing.ILicensingService
-keeppublicabstractinterfacecom.asqw.android.Listener{
publicprotected<methods>;
}
-keeppublicclasscom.asqw.android{
publicvoidStart(java.lang.String);
}
-keepclasseswithmembernamesclass*{
native<methods>;
}
-keepclasseswithmembersclass*{
public<init>(android.content.Context,android.util.AttributeSet);
}
-keepclasseswithmembersclass*{
public<init>(android.content.Context,android.util.AttributeSet,int);
}
-keepclassmembersclass*extendsandroid.app.Activity{
publicvoid*(android.view.View);
}
-keepclassmembersenum*{
publicstatic**[]values();
publicstatic**valueOf(java.lang.String);
}
-keepclass*implementsandroid.os.Parcelable{
publicstaticfinalandroid.os.Parcelable$Creator*;
}
-ignorewarnings
关于配置文件的解释
-injarsandroidtest.jar【jar包所在地址】
-outjarsout【输出地址】
-libraryjars'D:\android-sdk-windows\platforms\android-9\android.jar'【引用的库的jar,用于解析injars所指定的jar类】
-optimizationpasses5
-dontusemixedcaseclassnames【混淆时不会产生形形色色的类名】
-dontskipnonpubliclibraryclasses【指定不去忽略非公共的库类。】
-dontpreverify【不预校验】
-verbose
-optimizations!code/simplification/arithmetic,!field/*,!class/merging/*【优化】
-keeppublicclass*extendsandroid.app.Activity 【不进行混淆保持原样】
-keeppublicclass*extendsandroid.app.Application
-keeppublicclass*extendsandroid.app.Service
-keeppublicclass*extendsandroid.content.BroadcastReceiver
-keeppublicclass*extendsandroid.content.ContentProvider
-keeppublicclass*extendsandroid.app.backup.BackupAgentHelper
-keeppublicclass*extendsandroid.preference.Preference
-keeppublicclasscom.android.vending.licensing.ILicensingService
-keeppublicabstractinterfacecom.asqw.android.Listener{
publicprotected<methods>;【所有方法不进行混淆】
}
-keeppublicclasscom.asqw.android{
publicvoidStart(java.lang.String);【对该方法不进行混淆】
}
-keepclasseswithmembernamesclass*{【保护指定的类和类的成员的名称,如果所有指定的类成员出席(在压缩步骤之后)】
native<methods>;
}
-keepclasseswithmembersclass*{【保护指定的类和类的成员,但条件是所有指定的类和类成员是要存在。】
public<init>(android.content.Context,android.util.AttributeSet);
}
-keepclasseswithmembersclass*{
public<init>(android.content.Context,android.util.AttributeSet,int);
}
-keepclassmembersclass*extendsandroid.app.Activity{【保护指定类的成员,如果此类受到保护他们会保护的更好】
publicvoid*(android.view.View);
}
-keepclassmembersenum*{
publicstatic**[]values();
publicstatic**valueOf(java.lang.String);
}
-keepclass*implementsandroid.os.Parcelable{【保护指定的类文件和类的成员】
publicstaticfinalandroid.os.Parcelable$Creator*;
}
出现can'tfindreferencedclass的警告时,可以在proguard.cfg中添加-ignorewarnings来解决。
相关推荐
adb shell cd system/app rm *.apk21. 获取管理员权限: adb root22. 启动Activity: adb shell am start -n 包名/包名+类名。