如何不捕获此类表错误糖?

时间:2018-06-28 08:42:17

标签: android sqlite sugarorm

我收到此错误
Caused by: android.database.sqlite.SQLiteException: no such table:
有什么办法可以抓住它。
我尝试了try and catch,但应用无法崩溃
我的代码

JsonStroageMilla jsonStroageMilla=new JsonStroageMilla();
jsonStroageMilla.findById(JsonStroageMilla.class,1);

我的课

    @Keep
    public class JsonStroageMilla extends SugarRecord {
        public JsonStroageMilla(){

        }
    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    String data,time;
  }


完整的错误代码

  

致命异常:主要                                                                   工艺:valyangadi,PID:16477                                                                   java.lang.RuntimeException:无法启动活动   ComponentInfo {com.app/ChecckoutActivity062802}:   android.view.InflateException:二进制XML文件第23行:二进制XML   文件行#32:错误放大类片段                                                                       在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)                                                                       在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)                                                                       在android.app.ActivityThread.-wrap11(ActivityThread.java)                                                                       在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1354)                                                                       在android.os.Handler.dispatchMessage(Handler.java:102)                                                                       在android.os.Looper.loop(Looper.java:148)                                                                       在android.app.ActivityThread.main(ActivityThread.java:5443)                                                                       在java.lang.reflect.Method.invoke(本机方法)                                                                       在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:728)                                                                       在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)                                                                    原因:android.view.InflateException:二进制XML文件第23行:   二进制XML文件第32行:膨胀类片段时出错                                                                       在android.view.LayoutInflater.inflate(LayoutInflater.java:539)                                                                       在android.view.LayoutInflater.inflate(LayoutInflater.java:423)                                                                       在android.view.LayoutInflater.inflate(LayoutInflater.java:374)                                                                       在android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)                                                                       在android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)                                                                       在com.shopify.sample.checkout.ChecckoutActivity062802.onCreate(ChecckoutActivity062802.java:18)                                                                       在android.app.Activity.performCreate(Activity.java:6245)                                                                       在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)                                                                       在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)                                                                       在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)                                                                       在android.app.ActivityThread.-wrap11(ActivityThread.java)                                                                       在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1354)                                                                       在android.os.Handler.dispatchMessage(Handler.java:102)                                                                       在android.os.Looper.loop(Looper.java:148)                                                                       在android.app.ActivityThread.main(ActivityThread.java:5443)                                                                       在java.lang.reflect.Method.invoke(本机方法)                                                                       在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:728)                                                                       在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)                                                                    原因:android.view.InflateException:二进制XML文件第32行:   错误夸大类片段                                                                       在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)                                                                       在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)                                                                       在android.view.LayoutInflater.rInflate(LayoutInflater.java:835)                                                                       在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)                                                                       在android.view.LayoutInflater.rInflate(LayoutInflater.java:838)                                                                       在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)                                                                       在android.view.LayoutInflater.rInflate(LayoutInflater.java:838)                                                                       在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)                                                                       在android.view.LayoutInflater.rInflate(LayoutInflater.java:838)                                                                       在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)                                                                       在android.view.LayoutInflater.parseInclude(LayoutInflater.java:971)                                                                       在android.view.LayoutInflater.rInflate(LayoutInflater.java:831)                                                                       在android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)                                                                       在android.view.LayoutInflater.inflate(LayoutInflater.java:515)                                                                       在android.view.LayoutInflater.inflate(LayoutInflater.java:423)                                                                       在android.view.LayoutInflater.inflate(LayoutInflater.java:374)                                                                       在android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)                                                                       在android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)                                                                       在com.shopify.sample.checkout.ChecckoutActivity062802.onCreate(ChecckoutActivity062802.java:18)                                                                       在android.app.Activity.performCreate(Activity.java:6245)                                                                       在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)                                                                       在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)                                                                       在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)                                                                       在android.app.ActivityThread.-wrap11(ActivityThread.java)                                                                       在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1354)                                                                       在android.os.Handler.dispatchMessage(Handler.java:102)                                                                       在android.os.Looper.loop(Looper.java:148)                                                                       在android.app.ActivityThread.main(ActivityThread.java:5443)                                                                       在java.lang.reflect.Method.invoke(本机方法)                                                                       在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:728)                                                                       在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)                                                                    造成原因:android.database.sqlite.SQLiteException:无此类表:   JSON_STROAGE_MILLA(代码1):,同时进行编译:SELECT * FROM   JSON_STROAGE_MILLA                                                                       在android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native   方法)                                                                       在android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)                                                                       在android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)                                                                       在android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)                                                                       在android.database.sqlite.SQLiteProgram。(SQLiteProgram.java:58)                                                                       在android.database.sqlite.SQLiteQuery。(SQLiteQuery.java:37)                                                                       在android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)                                                                       在android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)                                                                       在android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1163)                                                                       在android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1034)                                                                       在android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1240)                                                                       在com.orm.SugarRecord.find(SugarRecord.java:201)                                                                       在com.orm.SugarRecord.listAll(SugarRecord.java:127)                                                                     在

2 个答案:

答案 0 :(得分:1)

  • 尝试立即禁用
  • 首先从设备/仿真器中卸载应用。
  • 然后清理项目(Android Studio,Build,Clean Project)。
  • 现在运行您的应用程序。

答案 1 :(得分:0)

添加一个空的构造函数,并确保将数据库值更新为1,所以

public JsonStroageMilla() {}

<meta-data
android:name="VERSION"
android:value="2"/>