在使用api 10在模拟器Nexus S Platform 2.3.3上执行Android应用程序时出现以下错误。它适用于带有api 18的Nexus 4 Android 4.3.AppDatabase扩展了SQLiteOpenHelper。
代码:
public class AppController extends Application {
[...]
private static AppDatabase mDbo;
[...]
try {
// Here comes the crash, it crashes immediately, i cannot step into
mDbo = new AppDatabase( AppDatabase.NAME,null, new AppSQLiteCursor(),AppDatabase.VERSION) ;
}
}
错误堆栈跟踪:
12-14 23:04:01.996 1372-1372/com.example.myapp E/APP_ERROR﹕ VerifyError raised!
java.lang.VerifyError: com.example.myapp.database.AppDatabase
at com.example.myapp.AppController.onCreate(AppController.java:85)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3272)
at android.app.ActivityThread.access$2200(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:6)
我终于找到了VerifyError异常的罪魁祸首。这是由于SQLiteCantOpenDatabaseException,直到API 11才包含它。仅使用SQLiteException来捕获AppDatabase类中的错误。