用Proguard混淆ORMLite模型类 [英] Obfuscating ORMLite model classes with Proguard

查看:102
本文介绍了用Proguard混淆ORMLite模型类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些我想在代码中混淆的模型. 我知道我可以忽略整个模型包,但我不想这样做. 我尝试了一些proguard调整,并检查了所有相关帖子都无济于事. ORMlite不断抛出java.lang.RuntimeException: Unable to create application ...App: java.lang.IllegalArgumentException: Foreign field class ....f.p does not have id field.我通过 dex2jar 解决方案

由于ORMLite使用反射来保存或保留您的数据,因此他们想要实体的名称(即您用于保存或保留数据的类)的名称不混淆./p>

抛出此异常是因为ORMLite试图为其表查找Entity类,并且无法找到具有相似名称的类和成员.

请忽略使用以下代码对实体类进行混淆:

-keep class com.xyz.components.**
-keepclassmembers class com.xyz.components.** { *; } 

其中com.xyz.components是用于实体类的软件包.

我希望这会有所帮助!

I have a few models that I want to obfuscate in my code. I know that I could just ignore the whole model package but I don't want to do that. I tried a few proguard tweaks and checked all relevant posts to no avail. ORMlite keeps throwing java.lang.RuntimeException: Unable to create application ...App: java.lang.IllegalArgumentException: Foreign field class ....f.p does not have id field. I checked that the annotation is still there with dex2jar and jd, and it is still there.

I have this proguard configuration (and a lot more that obfuscates other parts):

aggressive stuff :

-mergeinterfacesaggressively
-allowaccessmodification
-optimizationpasses 5

-verbose
-dontskipnonpubliclibraryclasses
-dontpreverify
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

keep information needed by various frameworks:

-keepattributes *Annotation*
-keepattributes Signature
-keepattributes EnclosingMethod

ORMLITE related:

-keep class com.j256.**
-keepclassmembers class com.j256.** { *; }
-keep enum com.j256.**
-keepclassmembers enum com.j256.** { *; }
-keep interface com.j256.**
-keepclassmembers interface com.j256.** { *; }

Am I missing something or is this just not possible?

解决方案

As ORMLite uses reflection to save or retain your data, they want un-obfuscated name of entity (ie classes you are using to save or retain data).

This exception is thrown because ORMLite is trying to find the Entity classes for its tables and its not able to find the classes and members with similar name.

Just Ignore your entity classes from getting obfuscated using following code:

-keep class com.xyz.components.**
-keepclassmembers class com.xyz.components.** { *; } 

where com.xyz.components is your package for Entity classes.

I hope this helps!

这篇关于用Proguard混淆ORMLite模型类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆