启用proguard时,sqlite中的where子句会使我的应用程序崩溃

时间:2014-07-14 11:26:45

标签: android sqlite

我正在开发一个使用ORMlite库访问sqlite数据库的Android应用程序。方案如下。

  1. 我的应用程序在调试模式下工作正常,即没有模糊处理。
  2. 当我启用proguard时,应用程序崩溃在我使用WHERE子句从sqlite数据库访问数据的行。
  3. 如果我从代码中删除WHERE子句部分,即使在混淆之后,应用程序也能正常运行。
  4. 请查看我的proguard-project.txt和源代码。

    -keep class com.j256.**
    -keepclassmembers class com.j256.** { *; }
    -keep enum com.j256.**
    -keepclassmembers enum com.j256.** { *; }
    -keep interface com.j256.**
    -keepclassmembers interface com.j256.** { *; }
    
    -keep class com.j256.** {
        *;
    }
    
    -keepclassmembers class * {
    public <init>(android.content.Context);
    }
    
    -keepclasseswithmembers class * {
        public <init>(android.content.Context, android.util.AttributeSet);
    }
    
    -keepclasseswithmembers class * implements android.os.Parcelable {
        static android.os.Parcelable$Creator CREATOR;
    }
    
    -mergeinterfacesaggressively
    -allowaccessmodification
    -optimizationpasses 5
    
    -verbose
    -dontskipnonpubliclibraryclasses
    -dontpreverify
    
    
    -keepattributes *Annotation*
    -keepattributes Signature
    -keepattributes EnclosingMethod
    
    -keep public class * extends android.app.Acitivity
    -keep public class * extends android.app.Application
    -keep public class * extends android.app.Service
    -keep public class * extends android.content.BroadcastReceiver
    -keep public interface com.google.android.vending.licensing.ILicensingService
    -keep public class com.adityabirla.firstresponse.database.ormlite.model.Contact
    
    -keep public class * extends android.view.View {
        public <init>(android.content.Context);
        public <init>(android.content.Context, android.util.AttributeSet);
        public <init>(android.content.Context, android.util.AttributeSet, int);
        public void set*(...);
    }
    

    Java源文件

        private void loadPersonalGrid() {
            try {
                Dao<Note, Integer> noteDao = ORMManager.getInstance(
                        getBaseContext()).getNoteDao();
    
                QueryBuilder<Note, Integer> queryBuilder = noteDao.queryBuilder();
    
    //          queryBuilder.where().eq("category", Note.NOTE_CATEGORY_PERSONAL); // CRASHES WHEN ENABLED
                PreparedQuery<Note> preparedQuery = queryBuilder.prepare();
                List<Note> noteList = noteDao.query(preparedQuery);
                NoteGridListAdapter adapter = new NoteGridListAdapter(this, noteList, NOTE_TYPE.PERSONAL, this);
    
                grid_personal.setAdapter(adapter);
                grid_personal.setExpanded(true);
    
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    

0 个答案:

没有答案