与OrmLite和ProGuard的混淆问题 [英] Problems with OrmLite and proguard obfuscation

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

问题描述

当我使用Proguard的项目与OrmLite。我收到此的错误

When I use Proguard on project with OrmLite. I recieve this error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.package.name/com.package.name.activities.StartActivity}:
java.lang.IllegalStateException: Could not find OpenHelperClass because none of the generic parameters of class class com.package.name.activities.StartActivity extends OrmLiteSqliteOpenHelper.  You should use getHelper(Context, Class) instead.

我试着从 Proguard的所有recomendation与OrmLite在Android 并从他人资源,但没有结果。

I've tried all recomendation from Proguard with OrmLite on Android and from others resources but without results

推荐答案

在两者的ProGuard的项目文件,您的ProGuard的优化文件,把下面的(如果你使用的优化)。

Put the below in both your proguard-project file and your proguard-optimization file (if you use optimization).

 # Your application may contain more items that need to be preserved; 
 # typically classes that are dynamically created using Class.forName: 
 # ormlite uses reflection 
 -keep class com.j256.** { *; }
 -keep class com.j256.**
 -keepclassmembers class com.j256.**
 -keep enum com.j256.**
 -keepclassmembers enum com.j256.**
 -keep interface com.j256.**
 -keepclassmembers interface com.j256.**

-keepclassmembers class * { 
  public <init>(android.content.Context); 
} 

-keepattributes *Annotation*

和每一个模型类:

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

我不喜欢半句一位,但我厌倦了试图找到一个更好的解决方案。

I don't like the last part one bit, but I'm tired of trying to find a better solution.

这篇关于与OrmLite和ProGuard的混淆问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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