0

I configured ActiveAndroid at AndroidManifest.xml as described below:

<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>

Application class:

public class XXXApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        ActiveAndroid.initialize(this);
    }
}

Mode class is:

@Table(name = "Routes")
public class Route extends Model {
...

   public static List<Routes> all(){
      return new Select().from(Route.class).execute();
   }

}

Ps: I follow the documentation: https://github.com/pardom/ActiveAndroid/wiki/Getting-started

When call Routes.all() I got this error:

tried to execute code in unprepared class 'Lbr/com/xxx/xxx/xxxx/models/Route;'

Full stack is:

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)
Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
seufagner
  • 1,290
  • 2
  • 18
  • 25

2 Answers2

5

This is late but could help someone else who faces the same problem. This problem only occurs in debug mode, To solve it :

  • remove any watched expressions (In Debug View) that involve that unprepared class.
  • If you don't use that class in your code just remove it (which solve the first point too). Hope it helps.
Driss Bounouar
  • 3,182
  • 2
  • 32
  • 49
1

Did you remember to write a standard constructor for Route? E. g.

public Route(){
    super();
}

And if you have your own Application class, it must be derived from com.activeandroid.app.Application:

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

If that doesn’t help, please post the signature of Route.

Loxley
  • 1,781
  • 17
  • 20
  • Thanks Loxley. Route class already has default constructor. Exists three ways to configure ActiveAndroid: extending `com.activeandroid.app.Application`, calling `ActiveAndroid.initialize(this);` at MyApplication#onCreate method or simply configuring `com.activeandroid.app.Application` at AndroidManifest.xml. I tried all ways and none works. What do you want say with signature? See the Route class at this gist: https://gist.github.com/seufagner/5134329 – seufagner Mar 11 '13 at 13:43
  • Hi Seufagner! I tried your code and it works for me. (I removed the references to RouteCoordinate, RouteStep etc.: http://pastebin.com/E7NPawxH generates:CREATE TABLE Routes (Id INTEGER PRIMARY KEY AUTOINCREMENT, travelMode INTEGER, idPNI INTEGER, name TEXT, duration TEXT, distance TEXT, polylineCode TEXT, summary TEXT);.) Could you show me the serializer/Deserializer for RouteCoordinate? – Loxley Mar 12 '13 at 14:55
  • Works for me too, Loxley.. this error happens only on debug mode.. anyway, I didn't create any serializer/deserializer for composition dependencies. – seufagner Mar 12 '13 at 17:05