SQLite的DbHelper不与艺术作品 [英] SQLite DbHelper doesn't work with ART

查看:212
本文介绍了SQLite的DbHelper不与艺术作品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个SQLite数据库在我的Andr​​oid应用程序,但不幸的是在新的虚拟机技术就停止工作。
我得到一个errore在DbHelper类,特别是当我打开数据库的读/写它。

我需要帮助!在此先感谢!

这是logcat的:

  11月11日至22日:57:05.600:E / AndroidRuntime 1435:致命异常:主要
十一月11日至22日:57:05.600:E / AndroidRuntime(1435):工艺:com.itc.zappapp,PID:1435
11月11日至22日:57:05.600:E / AndroidRuntime(1435):java.lang.VerifyError:拒绝类com.itc.zappapp.database.database_zappapp $ DbHelper,因为它没有编译时验证(com.itc的声明。 zappapp.database.database_zappapp $ DbHelper'出现在/data/app/com.itc.zappapp-1/base.apk)
11月11日至22日:57:05.600:E / AndroidRuntime 1435:在com.itc.zappapp.database.database_zappapp.open(database_zappapp.java:19530)
11月11日至22日:57:05.600:E / AndroidRuntime(1435):在com.itc.zappapp.Activity_Head.Activity_Splash.onCreate(Activity_Splash.java:75)
11月11日至22日:57:05.600:E / AndroidRuntime(1435):在android.app.Activity.performCreate(Activity.java:5933)
11月11日至22日:57:05.600:E / AndroidRuntime(1435):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
11月11日至22日:57:05.600:E / AndroidRuntime(1435):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)

编辑:
与Dalvic虚拟机的DB工作完美。

这是codeS为DbHelper:

  // versione iniziale
私有静态最终诠释DATABASE_VERSION = 1;私人DbHelper ourHelper;
私人最终上下文ourContext;
公共SQLiteDatabase ourDatabase;私有静态类DbHelper扩展SQLiteOpenHelper {    公共DbHelper(上下文的背景下){
        超(背景下,DATABASE_NAME,空,DATABASE_VERSION);
        // TODO自动生成构造函数存根
    }    //些插入.......    @覆盖
    公共无效的onCreate(SQLiteDatabase DB){
        //一些上创建........        插();        //一些更新...
    }    @覆盖
    公共无效onUpgrade(SQLiteDatabase分贝,INT oldVersion,诠释静态网页){
        //一些DROP TABLE .....
        的onCreate(DB);    }}公共database_zappapp(上下文C){
    ourContext = C;
}公共database_zappapp的open()抛出的SQLException {    ourHelper =新DbHelper(ourContext); < ---------的错误是在这里!
    ourDatabase = ourHelper.getWritableDatabase();
    返回此;
}公共无效的close(){    ourHelper.close();}


解决方案

我有错误:
java.lang.VerifyError:拒绝类com.ford.syncV4.android.module.ModuleTest,因为它没有编译时验证com.ford.syncV4.android.module.ModuleTest'的(声明出现在/数据/应用程序/ COM .ford.syncV4.android-1 / base.apk)

顺便说一句出现在Android操作系统5.0.1这个错误。

什么是错的我是这样的:

  {尝试
   同步(本){
      this.wait(100);
   }
}赶上(InterruptedException的E){
   / *异常信息都可以在这里捕捉* /
}

!! try / catch块内同步块!

当我设置的try / catch里面synchronized块 - 应用程序开始工作如常。顺便说一下,之前Android操作系统5.0.1有与这样的方法也没有问题。我认为,这是因为新的艺术编译器。

所以,正确的code正在寻找这样的:

 同步(本){
   尝试{
      this.wait(testActionItem.getDelay());
   }赶上(InterruptedException的E){
      / *异常信息都可以在这里捕捉* /
   }
}

此外,还有在Android问题跟踪器发射的一个问题:
发行80961

I have a SQLite Database in my android app but unfortunately with the new virtual machine ART it stop working. I get an errore in the DbHelper class, specifically when I open the database to write/read it.

I need help! Thanks in advance!

This is the logCat:

11-22 11:57:05.600: E/AndroidRuntime(1435): FATAL EXCEPTION: main
11-22 11:57:05.600: E/AndroidRuntime(1435): Process: com.itc.zappapp, PID: 1435
11-22 11:57:05.600: E/AndroidRuntime(1435): java.lang.VerifyError: Rejecting class com.itc.zappapp.database.database_zappapp$DbHelper because it failed compile-time verification (declaration of 'com.itc.zappapp.database.database_zappapp$DbHelper' appears in /data/app/com.itc.zappapp-1/base.apk)
11-22 11:57:05.600: E/AndroidRuntime(1435):at com.itc.zappapp.database.database_zappapp.open(database_zappapp.java:19530)
11-22 11:57:05.600: E/AndroidRuntime(1435):at com.itc.zappapp.Activity_Head.Activity_Splash.onCreate(Activity_Splash.java:75)
11-22 11:57:05.600: E/AndroidRuntime(1435): at android.app.Activity.performCreate(Activity.java:5933)
11-22 11:57:05.600: E/AndroidRuntime(1435): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
11-22 11:57:05.600: E/AndroidRuntime(1435): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)

Edit: The db work perfectly with Dalvic Virtual Machine.

This is the codes for the DbHelper:

// versione iniziale
private static final int DATABASE_VERSION = 1;

private DbHelper ourHelper;
private final Context ourContext;
public SQLiteDatabase ourDatabase;

private static class DbHelper extends SQLiteOpenHelper {

    public DbHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        // TODO Auto-generated constructor stub
    }

    //SOME INSERTS.......

    @Override
    public void onCreate(SQLiteDatabase db) {
        //SOME ON CREATE........

        insert();

        //some updates...




    }



    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        //some drop table.....
        onCreate(db);

    }

}

public database_zappapp(Context c) {
    ourContext = c;
}

public database_zappapp open() throws SQLException {

    ourHelper = new DbHelper(ourContext);    <--------- The error is here!!
    ourDatabase = ourHelper.getWritableDatabase();
    return this;
}

public void close() {

    ourHelper.close();

}

解决方案

I have the error: java.lang.VerifyError: Rejecting class com.ford.syncV4.android.module.ModuleTest because it failed compile-time verification (declaration of 'com.ford.syncV4.android.module.ModuleTest' appears in /data/app/com.ford.syncV4.android-1/base.apk)

By the way this error occur at the Android OS 5.0.1.

What were wrong for the me is this:

try {
   synchronized (this) {
      this.wait(100);
   }
} catch (InterruptedException e) {
   /* Exception message can be captured here */
}

!! Synchronized block inside try / catch block !!

When I set try / catch inside synchronized block - application start working as usual. By the way, prior to Android OS 5.0.1 there were no problem with such approach. I assume that this is because of the new ART compiler.

So, the correct code is looking like this:

synchronized (this) {
   try {
      this.wait(testActionItem.getDelay());
   } catch (InterruptedException e) {
      /* Exception message can be captured here */
   }
}

Also, there is an issue fired in the Android issue tracker: Issue 80961

这篇关于SQLite的DbHelper不与艺术作品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆