pardom-zz / ActiveAndroid

Active record style SQLite persistence for Android
http://www.activeandroid.com
4.7k stars 1.03k forks source link

Android activeAndroid get TableInfo.getIdName() error #500

Open pishguy opened 8 years ago

pishguy commented 8 years ago

I'm trying to implementing ActiveAndroid library on my project, after read more documentation about that, i get this error when i try to save data on database

com.activeandroid.TableInfo.getIdName()' on a null object reference

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.pishguy.XXX"
          xmlns:android="http://schemas.android.com/apk/res/android">

    ..

    <application
        android:name=".Application"

        ...

        <meta-data
            android:name="AA_DB_NAME"
            android:value="myDB.db"/>
        <meta-data
            android:name="AA_DB_VERSION"
            android:value="1"/>

    </application>

</manifest>

Application class:

public void onCreate() {
    super.onCreate();

    ...

    ActiveAndroid.initialize(this);
}

DataBase model:

@Table(name = "MyClass")
public class MyClass extends Model {
    @Column(name = "Name")
    private String Name;

    ...

    @Column(name = "updated_at")
    private String updated_at;

    public MyClass() {
        super();
    }

    ...
}

and then using that:

MyClass class     = new MyClass();
    class.setName       (classItems.getString("name"));
    ...
    class.setCreated_at(classItems.getString("created_at"));
    class.setUpdated_at(classItems.getString("updated_at"));

    ...
BryceLee commented 8 years ago

I guess you are using Android studio and Gradle 2.0+. you can specify your Model classes explicitely in your AndroidManifest: <meta-data android:name="AA_MODELS" android:value="com.myapp.model.Item, com.myapp.model.Category" />

pishguy commented 8 years ago

@leezx1993 this library supported yet? or not?

BryceLee commented 8 years ago

you can specify your Model classes explicitely in your AndroidManifest: android:name="AA_MODELS" android:value="com.myapp.model.Item, com.myapp.model.Category" /> it will work well~

sunil6525 commented 7 years ago

still its not working.. same error

sourena21 commented 6 years ago

same error