转载:混淆包含SlidingMenu、gson等Android代码的proguard写法
描述:作为一个写了几年c#的码农,咱的java水平实在不敢恭维,但是最近有个任务需要弄点java的代码,还要研究混淆。网上百度并实验了整整一天,终于算是有点成果了。其中混淆的时候由于用到了gson包,导致混淆后代码不能正常执行,看到了这篇文章,摘抄了其中关于gson设置的一段配置,就好了,不敢私藏分享一下。原文转载。
原文链接:http://blog.csdn.net/sgwhp/article/details/9336695
在混淆包含SlidingMenu的代码时,可能会报以下错误:
can't find superclass or interface com.google.android.maps.MapActivity
...
如果还使用到了gson来序列化或者反序列化json,程序还会抛出NullPointerException,这是因为代码被混淆后,成员变量以及getter、setter的名字都变了,这样就不能正常的序列化。
jni同理。
以下是本人使用的proguard.cfg,遇到此类错误的可以参考一下:
-dontpreverify -repackageclasses '' -allowaccessmodification -optimizations !code/simplification/arithmetic -keepattributes *Annotation* -verbose -dontskipnonpubliclibraryclassmembers-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.support.v4.app.FragmentActivity -keep public class * extends android.support.v4.app.Fragment-keep public class * extends android.view.View {public <init>(android.content.Context);public <init>(android.content.Context, android.util.AttributeSet);public <init>(android.content.Context, android.util.AttributeSet, int);public void set*(...); }-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.content.Context {public void *(android.view.View);public void *(android.view.MenuItem); }-keepclassmembers class * implements android.os.Parcelable {static android.os.Parcelable$Creator CREATOR; }-keepclassmembers class **.R$* {public static <fields>; }# 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>; }-keepclasseswithmembernames class * {public <init>(android.content.Context, android.util.AttributeSet); }-keepclasseswithmembernames 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 *; }##---------------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.** { *; } -keep class com.google.gson.examples.android.model.** { *; } -keep class com.google.gson.** { *;}# Application classes that will be serialized/deserialized over Gson -keep class com.antew.redditinpictures.library.imgur.** { *; } -keep class com.antew.redditinpictures.library.reddit.** { *; }##---------------End: proguard configuration for Gson -----------dontwarn android.support.** -dontwarn com.google.android.maps.** -dontwarn com.slidingmenu.lib.app.SlidingMapActivity -keep class android.support.** { *; } -keep class com.actionbarsherlock.** { *; } -keep interface com.actionbarsherlock.** { *; } -keep class com.slidingmenu.** { *; } -keep interface com.slidingmenu.** { *; } #所有实体类所在包 -keep class org.hdstar.common.**{ *; }
对作者便是感谢
转载于:https://www.cnblogs.com/yuanyuan/p/3615105.html
转载:混淆包含SlidingMenu、gson等Android代码的proguard写法相关推荐
- 混淆包含SlidingMenu、gson等Android代码的proguard写法
在混淆包含SlidingMenu的代码时,可能会报以下错误: can't find superclass or interface com.google.android.maps.MapActivit ...
- Android代码混淆之混淆规则
请尊重他人的劳动成果,转载请注明出处:<Android代码混淆技巧> 因为Android是使用Java开发的,所以开发者可以使用ProGuard对代码进行混淆.SDK已经集成了ProGua ...
- Android 代码混淆Proguard
混淆概念 Android代码混淆,又称Android混淆,是伴随着Android系统的流行而产生的一种APP保护技术,用于保护APP不被破解和逆向分析. 在Android的具体表现就是打包时,将项目里 ...
- android 代码混淆 gson,Android RecyclerView和Gson混淆问题
RecyclerView 配置混淆 release打包后发现RecyclerView不显示数据, 推测是反射没有加混淆问题, 具体置如下 # When layoutManager xml attrib ...
- Android 代码混淆语法讲解及常用模板(转)
转载请注明原博客地址 Android 代码混淆语法讲解及常用模板 前言 混淆对于每一个开发者来说都不陌生,对于大多数 APP 而言,在上线之前,通常会进行代码混淆,加固,防止自己的 APP 被别人轻 ...
- android 代码混淆示例
参考其它资料为项目代码做了一下混淆 项目中使用了 slidingmenu actionbarsherlock fastjson volley httpclient 等第三方库, 并使用了 ...
- android aidl混淆代码,Android代码混淆
什么是代码混淆 代码混淆就是将代码中的各种元素,如变量,方法,类和包的名字改写成无意义的名字,增加项目反编译后被读懂的难度. Android代码混淆使用ProGuard工具,ProGuard是一个压缩 ...
- android 混淆后的机制,Android 代码混淆机制
Android 代码混淆机制 由于Android项目是基于java语言的,而java属于高层抽象语言,易于反编译,其编译后的程序包包含了大量的源代码变量.函数名.数据结构等信息,根据其编译打包后的AP ...
- android 代码混淆
简介 Java代码是非常容易反编译的.为了很好的保护Java源代码,我们往往会对编译好的class文件进行混淆处理. ProGuard是一个混淆代码的开源项目.它的主要作用就是混淆,当然它还能对字节码 ...
最新文章
- linux 修改用户组_linux小白到大神的成长之路:linux系统用户组的管理!
- php css错乱,css,html_css多行布局错乱,css,html - phpStudy
- 数据科学家为什要用Git?怎么用?
- harbor重置mysql密码_Harbor密码重置 密码修改 admin密码重置
- Python——验证码识别 安装Pillow、tesseract-ocr与pytesseract模块的安装以及错误解决
- 分布式实时日志分析解决方案 ELK 部署架构
- python修改pdf文件大小,python读pdf文件字体大小_用Python读取pdf文件
- 置入式模型inclusion model和显示具现化
- oracle迁移mysql验证_ORACLE 迁移MYSQL 随笔
- NYOJ845 - 无主之地1
- 快递100手机端页面抓取所有快递公司名称和代码
- camera hardware module
- osip和mysql_osip2/eXosip2调试笔记
- Ubuntu 下安装 Vysor投屏软件
- mysql front下载,MySQL-Front下载
- springboot项目启动遇到问题:AopAutoConfiguration matched: - @ConditionalOnProperty (spring.aop.auto=true)
- 键盘的某些键坏了咋办(如delete键等)
- 如何才能高效的学习,99%的人不知道的高效学习法
- wex5 实战 常用代码模型集合
- HDU 4069 Squiggly Sudoku Dancing-Links(DLX)+Floodfill
热门文章
- Android中RAS加密解密
- Gly-Phe-Leu, 15373-56-5
- android 查询快捷方式,android桌面快捷方式的创建和查询
- ESP8266模拟输入引脚不够用怎么办——CD74HC4067使用一路ADC 采集16路模拟信号
- RBAC(Role-Based Access control)权限模型--基于角色的权限分配解决方案
- 500 Casual Expressions Commonly Used
- CDR X8中的图框精确剪裁不见了,怎么找回?
- 笔试强训错题总结(一)
- Oracle快速入门 | 黑马
- 什么是站群服务器?站群服务器性能如何?