android - No Such Column Sugar ORM 仅在发布版本中

标签 android database sugarorm

我正在使用如下所示的代码,但不知何故,在调试版本中一切都运行良好,但一旦我编译应用程序的发布版本,我就会收到错误。

没有这样的列: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/

相关文章:

java - Android RecyclerView 存在 EditText 洗牌问题

android - 禁用工具栏滚动

mysql - 我如何实现数据库以及如何正确链接每个按钮

android - 使用 Retrofit 在 SugarRecord 中找不到表

java - 数据库更改时 RecyclerView 不更新

android - android :attr/textAppearanceMedium and ? android :textAppearanceMedium? 有什么区别?

android - Android In-app Billing Library 与 In-app Billing API 哪个有更好的优势

php - 将 MySQL 中的数据显示到 bootstrap 模式中(无 ajax)

mysql - 在mysql(innodb)中,大表如何影响缓冲区(内存)?

android - 如何使用 Sugar ORM 的 count() 方法?