由于sqliteexception无法启动Debug Build Variant

时间:2019-08-13 10:44:54

标签: android sqlite android-studio

我再也无法启动调试构建变体,但是发行版确实可以工作。当我尝试启动我的应用程序时,它将引发SQLiteException。以前它像魔术一样工作,当我将compileSdkVersion和targetSdkVersion从27更新为28(Android 9)时,出现了问题(iirc),从那时起我就不能再使用调试了。我该怎么做才能使调试模式再次运行?

我已经尝试从手机上彻底擦除该应用程序,尝试使用模拟器并尝试清理并重建。我的同事仍然可以使用调试模式,所以我很确定这是本地问题。

尝试启动应用程序时,堆栈跟踪的重要部分就会出现:

 (...)
    Caused by: android.database.sqlite.SQLiteException: no such table: DSEARCHES (Sqlite code 1 SQLITE_ERROR): , while compiling: SELECT * FROM DSEARCHES WHERE MARKET = ?, (OS error - 2:No such file or directory)
 (...) 

由于被请求:我的数据库“ Dsearches”仅通过toString扩展了SugarRecord,所以我在那里什么都没写。导致代码的问题是(请注意,此行在AsyncTask中执行):

List<Dsearches> dsearches = MyApp.get().getDsearchesForCurrentMarket();

和getDsearchesForCurrentMarket方法:

public List<Dsearches> getDsearchesForCurrentMarket() {
        return Dsearches.find(Dsearches.class, "MARKET = ?", getCurrentMarket());
    }

Dsearches类:

public class Dsearches extends SugarRecord{

    public String market;
    public String label;
    public String startDate;
    @Ignore
    public int count = 0;

    @Override
    public String toString() {
        String result = label + "\n";
        if(count > 0) {
            result += "Es wurden " + count + " neue Jobs gefunden.";
        } else {
            result += "Wir informieren Sie, sobald neue Jobs gefunden \nwurden.";
        }
        return result;
    }
}

完整的堆栈跟踪:

E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
    Process: de.jobware.app.debug, PID: 31687
    java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:355)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
        at java.util.concurrent.FutureTask.run(FutureTask.java:271)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:246)
        at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:784)
     Caused by: android.database.sqlite.SQLiteException: no such table: DSEARCHES (Sqlite code 1 SQLITE_ERROR): , while compiling: SELECT * FROM DSEARCHES WHERE MARKET = ?, (OS error - 2:No such file or directory)
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:948)
        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:559)
        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:603)
        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:63)
        at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
        at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
        at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1493)
        at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1335)
        at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1206)
        at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1412)
        at com.orm.SugarRecord.find(SugarRecord.java:201)
        at com.orm.SugarRecord.find(SugarRecord.java:187)
        at de.jobware.jana.JobwareApp.getDsearchesForCurrentMarket(MyApp.java:256)
        at de.jobware.jana.activity.StartActivity$3.doInBackground(StartActivity.java:133)
        at de.jobware.jana.activity.StartActivity$3.doInBackground(StartActivity.java:113)
        at android.os.AsyncTask$2.call(AsyncTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:246) 
        at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:784) 

Sugar Record是给定的数据库实现,可下载 here

0 个答案:

没有答案