Android代码混淆的使用
来源:互联网 发布:php高级程序员面试题 编辑:程序博客网 时间:2024/04/28 16:57
这几天项目要打包上线,所以考虑到了是否要将代码混淆呢,答案当然是肯定的啦
当然网上有关的博客文章一大堆,经过多方探索与测试,最终实现了代码混淆,在此,先贴上混淆的脚本文件代码
最靠谱的回答是在stackoverflow上一位大神的回答详见,部分也是借鉴了他的代码
# To enable ProGuard in your project, edit project.properties# to define the proguard.config property as described in that file.## Add project specific ProGuard rules here.# By default, the flags in this file are appended to flags specified# in ${sdk.dir}/tools/proguard/proguard-android.txt# You can edit the include path and order by changing the ProGuard# include property in project.properties.## For more details, see# http://developer.android.com/guide/developing/tools/proguard.html# Add any project specific keep options here:# If your project uses WebView with JS, uncomment the following# and specify the fully qualified class name to the JavaScript interface# class:#-keepclassmembers class fqcn.of.javascript.interface.for.webview {# public *;#}##---------------Begin: proguard configuration common for all Android apps -----------optimizationpasses 5-dontusemixedcaseclassnames-dontskipnonpubliclibraryclasses-dontskipnonpubliclibraryclassmembers-dontpreverify-verbose-dump class_files.txt -printseeds seeds.txt -printusage unused.txt -printmapping mapping.txt -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*-allowaccessmodification-keepattributes *Annotation*-renamesourcefileattribute SourceFile-keepattributes SourceFile,LineNumberTable-repackageclasses ''-keep public class * extends android.app.Fragment -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 * extends android.support.v4.**-keep public class com.android.vending.licensing.ILicensingService-dontnote com.android.vending.licensing.ILicensingService# Explicitly preserve all serialization members. The Serializable interface# is only a marker interface, so it wouldn't save them.-keepclassmembers class * implements java.io.Serializable { static final long serialVersionUID; private static final java.io.ObjectStreamField[] serialPersistentFields; private void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve();}# Preserve all native method names and the names of their classes.-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);}# Preserve static fields of inner classes of R classes that might be accessed# through introspection.-keepclassmembers class **.R$* { public static <fields>;}# Preserve the special static methods that are required in all enumeration classes.-keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String);}-keep public class * { public protected *;}-keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *;}-keepclassmembers class * extends android.app.Activity { public void *(android.view.View);}-keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String);}##---------------End: proguard configuration common for all Android apps -----------keep class com.raipeng.photograph.control.model.** { *; } #shareSDK-keep class cn.sharesdk.**{*;}-keep class com.sina.**{*;}-keep class **.R$* {*;}-keep class **.R{*;}-dontwarn cn.sharesdk.**-dontwarn **.R$*-libraryjars libs/armeabi/libBaiduMapSDK_v2_3_0.so-libraryjars libs/armeabi/liblocSDK3.so-libraryjars libs/baidumapapi_v2_3_0.jar -keep class com.baidu.** { *; }-keep class vi.com.gdi.bgl.android.**{*;}##---------------Begin: proguard configuration for Gson ----------# Gson uses generic type information stored in a class file when working with fields. Proguard# removes such information by default, so configure it to keep all of it.-keepattributes Signature# Gson specific classes-keep class sun.misc.Unsafe { *; }#-keep class com.google.gson.stream.** { *; }# Application classes that will be serialized/deserialized over Gson-keep class com.google.gson.examples.android.model.** { *; }##---------------End: proguard configuration for Gson -----------libraryjars libs/alipay_msp.jar-keep class com.alipay.android.app.IAliPay{*;}-keep class com.alipay.android.app.IAlixPay{*;}
0 0
- Android代码混淆的使用
- android代码的混淆
- Android 使用 ProGuard 混淆代码
- 使用proguard混淆android代码
- 使用proguard混淆android代码
- 使用proguard混淆android代码
- 使用proguard混淆android代码
- 使用ProGuard混淆Android代码
- 使用ProGuard混淆Android工程 保护好自己的代码
- Android studio的使用 -- 代码混淆与打包
- Android代码混淆的实践
- Android代码混淆的实践
- Android 代码混淆的实践
- Android下的代码混淆
- Android 代码混淆的实践
- Android代码混淆的注意事项
- Android Studio的代码混淆
- 2.10 Android 代码的混淆
- 诺贝尔物理学奖揭晓:LED灯将点亮整个21世纪
- Eclipsed 平台下c/c++的开发
- HDU 4821 String 字符串哈希
- 互联网产品中的细枝末节(1)
- Fragment之间的通信
- Android代码混淆的使用
- 排序-c语言实现(摘自数据结构与算法分析c语言实现)
- 黑马程序员_JAVA_银行调度管理系统
- C++ Primer学习笔记6 标准库类型(命名空间的using声明、标准库string类型)
- 优先队列(堆) - C语言实现(摘自数据结构与算法分析 C语言描述)
- 实例介绍Cocos2d-x中Box2D物理引擎:HelloBox2D
- 嵌入式 VFS: Cannot open root device "mtdblock2" or unknown-block(2,0)
- 谷歌构筑互联网生态 探秘谷歌气球+光纤
- String类的字符串操作(C++实现)