0

我在 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)
4

2 回答 2

5

这已经晚了,但可以帮助面临同样问题的其他人。此问题仅在调试模式下出现,要解决它:

  • 删除任何涉及该未准备类的监视表达式(在调试视图中)。
  • 如果您不在代码中使用该类,只需将其删除(这也解决了第一点)。希望能帮助到你。
于 2015-04-29T09:52:26.797 回答
1

您还记得为 Route 编写标准构造函数吗?例如。

public Route(){
    super();
}

如果你有自己的 Application 类,它必须派生自com.activeandroid.app.Application

public class Application extends com.activeandroid.app.Application {
    …
}

如果这没有帮助,请张贴 Route 的签名。

于 2013-03-09T06:45:53.053 回答