1

I'm using codes as shown below, but somehow everything is working perfectly fine in debug version but as soon as I compile release version of the app, I get the error.

no such column: IMAGE_ID

Currently using sugarORM version 1.3 also using 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;
    }
}

This is the query i am using to find the image_id

List<Favorite> favorites = Favorite.find
                (Favorite.class, "IMAGE_ID = ?", ((String) ("" + imageId)));
        if (!favorites.isEmpty()) {
            return favorites.get(0);
        }

I've tried using image_id Image_Id image_Id image_ID and few other but I always get error `no such column exception in my release version of my application.

I have also tried many suggestion asked in the such type of question(s) but nothing is working as expected.

4

2 回答 2

3

AS @Harsh mentioned you need to add rules to skip the obfuscation of classes are extending SugarRecord and SugarApp.This is just another way of doing the same thing.

 #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.** { *; }

Related Issues

https://github.com/satyan/sugar/issues/219

https://github.com/satyan/sugar/issues/395

Extra: Use following rule to enable line numbers in logcat when running a proguard enabled apk build, be sure to remove when publishing.

-keepattributes SourceFile,LineNumberTable

Otherwise logcat lines will be like following

at android.support.v4.app.Fragment.b(Unknown Source)

Make sure to remove it when publishing.

于 2015-12-29T09:03:36.487 回答
2

I'm using SugarORM with proguard, which also obfuscate the model ( databases ) classes.

In order to use SugarORM with proguard you need to update proguard setting so that will it not obfuscate your database classes.

-keep public class com.youcompany.appname.xx.<ClassName> extends SugarRecord{*;}
-keep public class com.youcompany.appname.XX.<ClassName> extends SugarApp{*;}
于 2015-07-15T10:56:48.423 回答