我正在开发一个使用ORMlite库访问sqlite数据库的Android应用程序。方案如下。
请查看我的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();
}
}