我正在使用如下所示的代码,但不知何故,在调试版本中一切都运行良好,但一旦我编译应用程序的发布版本,我就会收到错误。
没有这样的列:IMAGE_ID
目前正在使用 sugarORM 1.3 版也正在使用 proguard
public class Favorite extends SugarRecord<Favorite> {
private int imageId;
private int licenseId;
public Favorite(int imageId, int licenseId){
this.imageId = imageId;
this.licenseId = licenseId;
}
}
这是我用来查找 image_id
的查询List<Favorite> favorites = Favorite.find
(Favorite.class, "IMAGE_ID = ?", ((String) ("" + imageId)));
if (!favorites.isEmpty()) {
return favorites.get(0);
}
我试过使用 image_id
Image_Id
image_Id
image_ID
和其他几个
但我总是出错
`在我的应用程序的发布版本中没有这样的列异常。
我也尝试过在此类问题中提出的许多建议,但没有任何效果符合预期。
最佳答案
AS @Harsh 提到您需要添加规则以跳过正在扩展 SugarRecord 和 SugarApp 的类的混淆。这只是做同样事情的另一种方式。
#skip every public class that extends com.orm.SugarRecord
#and their public/protected members
-keep public class * extends com.orm.SugarRecord {
public protected *;
}
-keep class com.orm.** { *; }
相关问题
https://github.com/satyan/sugar/issues/219
https://github.com/satyan/sugar/issues/395
额外: 在运行启用混淆器的 apk 构建时,使用以下规则在 logcat 中启用行号,确保在发布时删除。
-keepattributes SourceFile,LineNumberTable
否则 logcat 行将如下所示
at android.support.v4.app.Fragment.b(Unknown Source)
确保在发布时将其删除。
关于android - No Such Column Sugar ORM 仅在发布版本中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31427733/