在 OrmLite 中找不到适合私有布尔值的 get 方法
Could not find appropriate get method for private boolean in 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.access0(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.(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)
奇怪的是我在我的实体 class 中定义了一个 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;
}
感谢@Gray 的建议。更新我的方法并使用来自主干的最新方法似乎已经解决了我的问题。
我在 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.access0(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.(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)
奇怪的是我在我的实体 class 中定义了一个 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;
}
感谢@Gray 的建议。更新我的方法并使用来自主干的最新方法似乎已经解决了我的问题。