我在 AndroidManifest.xml 中配置了 ActiveAndroid,如下所述:
<application
android:name="com.xxx.xxxx.XXXApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
<meta-data
android:name="AA_DB_NAME"
android:value="MyDB.db" />
<meta-data
android:name="AA_DB_VERSION"
android:value="2" />
...
</application>
应用类:
public class XXXApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ActiveAndroid.initialize(this);
}
}
模式类是:
@Table(name = "Routes")
public class Route extends Model {
...
public static List<Routes> all(){
return new Select().from(Route.class).execute();
}
}
Ps:我按照文档: https ://github.com/pardom/ActiveAndroid/wiki/Getting-started
当调用 Routes.all() 我得到这个错误:
试图在未准备好的类“Lbr/com/xxx/xxx/xxxx/models/Route;”中执行代码
全栈是:
03-08 16:41:56.505: E/dalvikvm(23688): ERROR: tried to execute code in unprepared class 'Lbr/com/xxx/xxx/xxxx/models/Route;' (5)
03-08 16:41:56.505: I/dalvikvm(23688): "main" prio=5 tid=1 RUNNABLE
03-08 16:41:56.505: I/dalvikvm(23688): | group="main" sCount=0 dsCount=0 obj=0x41800508 self=0x417efce0
03-08 16:41:56.505: I/dalvikvm(23688): | sysTid=23688 nice=0 sched=0/0 cgrp=apps handle=1075560240
03-08 16:41:56.505: I/dalvikvm(23688): | schedstat=( 1596851683 269907401 1132 ) utm=148 stm=11 core=0
03-08 16:41:56.505: I/dalvikvm(23688): at com.xxxx.models.Route.all(Route.java:-1)
03-08 16:41:56.505: I/dalvikvm(23688): at com.xxxx.activities.SavedRoutesActivity.onCreate(SavedRoutesActivity.java:-1)
03-08 16:41:56.505: I/dalvikvm(23688): at com.xxxx.activities.SavedRoutesActivity_.onCreate(SavedRoutesActivity_.java:24)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.Activity.performCreate(Activity.java:5206)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread.access$600(ActivityThread.java:140)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
03-08 16:41:56.505: I/dalvikvm(23688): at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 16:41:56.505: I/dalvikvm(23688): at android.os.Looper.loop(Looper.java:137)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-08 16:41:56.505: I/dalvikvm(23688): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 16:41:56.505: I/dalvikvm(23688): at java.lang.reflect.Method.invoke(Method.java:511)
03-08 16:41:56.505: I/dalvikvm(23688): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
03-08 16:41:56.505: I/dalvikvm(23688): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
03-08 16:41:56.505: I/dalvikvm(23688): at dalvik.system.NativeStart.main(Native Method)
03-08 16:41:56.505: E/dalvikvm(23688): VM aborting
03-08 16:41:56.505: A/libc(23688): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 23688 (o.mobile.xxxx)