在我的AndroidManifest.xml配置ActiveAndroid如下所述: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 /模型/路由;'
完整的堆棧是:
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)
謝謝Loxley。路由類已經有默認的構造函數。 存在三種配置ActiveAndroid的方法:擴展'com.activeandroid.app.Application',在MyApplication#onCreate方法中調用'ActiveAndroid.initialize(this);'或者簡單地在AndroidManifest中配置'com.activeandroid.app.Application'。 XML。 我嘗試了所有方法,沒有任何工作。 你想用簽名說什麼? 請參閱路線類在這個要點:https://gist.github.com/seufagner/5134329 – seufagner 2013-03-11 13:43:42
嗨Seufagner!我試過你的代碼,它適用於我。 (我刪除了對RouteCoordinate,RouteStep等的引用:http://pastebin.com/E7NPawxH generate:CREATE TABLE Routes(Id INTEGER PRIMARY KEY AUTOINCREMENT,travelMode INTEGER,idPNI INTEGER,name TEXT,duration TEXT,distance TEXT,polylineCode TEXT ,summary TEXT);。)你可以向我展示RouteCoordinate的序列化器/解串器嗎? – Loxley 2013-03-12 14:55:32
也適用於我,Loxley ..這個錯誤只發生在調試模式.. 無論如何,我沒有創建任何序列化/反序列化器的組成依賴關係。 – seufagner 2013-03-12 17:05:15