我在模拟器上的Android Studio中运行Android应用程序时遇到了一个非常奇怪的错误。错误粘贴在下面。
我没有将SQLite用于db。我正在使用共享演出。代码中没有对USER_DATA_TABLE或SQLite的引用。
我唯一能看到USER_DATA_TABLE& amp; SQLite位于/build/generated/mockable-android-23.jar文件中,该文件显然是由构建过程生成的。我在构建应用程序并运行之前删除了整个构建文件夹。
你们中的任何一位专家都能给我一些解决方法吗?
访问SugarORM的代码片段是这样的:
public void redrawNavMenu() {
UserDataTable user = UserDataTable.findById(UserDataTable.class, 1L);
使用的findById方法是在SugarORM中
public static <T extends SugarRecord<?>> T findById(Class<T> type, Long id) {
List<T> list = find( type, "id=?", new String[]{String.valueOf(id)}, null, null, "1");
if (list.isEmpty()) return null;
return list.get(0);
}
我迷失在这里。那么如果USER_DATA_TABLE不在代码中的任何位置,那么它在哪里被访问?
日志:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.matt.quiz/com.matt.quiz.activities.QuizActivity}: android.database.sqlite.SQLiteException: no such table: USER_DATA_TABLE (code 1): , while compiling: SELECT * FROM USER_DATA_TABLE WHERE id=? LIMIT 1
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.database.sqlite.SQLiteException: no such table: USER_DATA_TABLE (code 1): , while compiling: SELECT * FROM USER_DATA_TABLE WHERE id=? LIMIT 1
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1163)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1034)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1240)
at com.orm.SugarRecord.find(SugarRecord.java:208)
at com.orm.SugarRecord.findById(SugarRecord.java:138)
at com.matt.quiz.activities.QuizActivity.redrawNavMenu(QuizActivity.java:461)
at com.matt.quiz.activities.QuizActivity.onCreate(QuizActivity.java:194)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
答案 0 :(得分:0)
终于找到了我自己的答案。它与清单文件中的数据库版本有关。该版本需要增量。