2013-11-03 74 views
5

我有幾個模型需要在我的代碼中進行模糊處理。 我知道我可以忽略整個模型包,但我不想這樣做。 我嘗試了一些proguard調整和檢查所有相關的帖子無濟於事。 ORMlite繼續投擲java.lang.RuntimeException: Unable to create application ...App: java.lang.IllegalArgumentException: Foreign field class ....f.p does not have id field。我檢查了註釋仍在dex2jarjd,它仍然存在。使用Proguard模糊ORMLite模型類

我有這樣的ProGuard配置(和更大量的是混淆其他部分):

積極的東西:

-mergeinterfacesaggressively 
-allowaccessmodification 
-optimizationpasses 5 

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

繼續通過各種框架所需的信息:

-keepattributes *Annotation* 
-keepattributes Signature 
-keepattributes EnclosingMethod 

ORMLITE相關:

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

我錯過了什麼,或者這是不可能的?

回答

5

由於ORMLite使用反射來保存或保留您的數據,他們希望實體(即您用於保存或保留數據的類)的未混淆名稱。

由於ORMLite正在嘗試爲其表找到實體類,並且無法找到具有相似名稱的類和成員,所以會拋出此異常。

只需使用下面的代碼混淆越來越忽略實體類:

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

其中com.xyz.components是你的包實體類。

我希望這有助於!

+2

我知道我可以這樣做,但我不想,也不明白爲什麼我必須這樣做,因爲註釋仍然存在。 – meredrica

相關問題