无法在OrmLite中找到适用于私有布尔值的get方法

时间:2015-08-25 13:37:29

标签: java android ormlite

我在Android应用程序中使用OrmLite,并且因以下错误而偶尔发生崩溃。看起来它抱怨没有找到一个getter方法。

java.lang.RuntimeException: Unable to start activity  ComponentInfo{com.app/com.app.MainActivity_}:  java.lang.IllegalArgumentException: Could not find appropriate get method for  private boolean com.app.model.User.isKeepAlive
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2760)
   at android.app.ActivityThread.access$900(ActivityThread.java:177)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:145)
   at android.app.ActivityThread.main(ActivityThread.java:5944)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1389)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)
Caused by: java.lang.IllegalArgumentException: Could not find appropriate get method for private boolean com.app.model.User.isKeepAlive
   at com.j256.ormlite.field.DatabaseFieldConfig.findGetMethod(DatabaseFieldConfig.java:548)
   at com.j256.ormlite.field.FieldType.(FieldType.java:236)
   at com.j256.ormlite.table.DatabaseTableConfig.convertFieldConfigs(DatabaseTableConfig.java:236)
   at com.j256.ormlite.table.DatabaseTableConfig.extractFieldTypes(DatabaseTableConfig.java:101)
   at com.j256.ormlite.dao.BaseDaoImpl.initialize(BaseDaoImpl.java:153)
   at com.j256.ormlite.dao.BaseDaoImpl.(BaseDaoImpl.java:128)
   at com.j256.ormlite.dao.BaseDaoImpl.(BaseDaoImpl.java:119)
   at com.j256.ormlite.dao.BaseDaoImpl$5.(BaseDaoImpl.java:921)
   at com.j256.ormlite.dao.BaseDaoImpl.createDao(BaseDaoImpl.java:921)
   at com.j256.ormlite.dao.DaoManager.createDao(DaoManager.java:72)
   at com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.getDao(OrmLiteSqliteOpenHelper.java:279)
   at com.app.utility.DatabaseHelper.getUserDao(DatabaseHelper.java:126)
   at com.app.controller.UserController.getLoggedInUser(UserController.java:318)
   at com.app.controller.UserController.isLoggedIn(UserController.java:304)

奇怪的是我在我的实体类中定义了一个get方法,如下所示:

@DatabaseField(useGetSet = true)
private boolean isKeepAlive;

/**
 * @return the isKeepAlive
 */
public boolean getIsKeepAlive() {
    return isKeepAlive;
}

/**
 * @param isKeepAliveSet the isKeepAliveSet to set
 */
public void setIsKeepAlive(boolean isKeepAlive) {
    this.isKeepAlive = isKeepAlive;
}

1 个答案:

答案 0 :(得分:0)

感谢@Gray的建议。更新我的方法并使用最新的trunk来解决我的问题。