java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.activeandroid.TableInfo.getIdName()' on a null object reference
Hi,
I'm getting a strange NullPointer exception on a fresh application that I'm creating (AndroidStudio 2/Android 6.0.1). Any thing that I'm missing?
Best
Sebastian
I am also getting this error.
I actually switched to Realm. It seems ActiveAndroid is not maintained anymore.
Maybe @svendvd could give us insights how his fix works :-)
It was working fine for me before now I updated DB model and am getting the above error. my app is almost complete.
Hi @sebastiandeutsch
I fixed my issue. It was because my model classes where not loading properly in to active android.
Hi this is my simple workaround. https://github.com/pardom/ActiveAndroid/pull/462
Hello, this is a huge blocker for us. Any chance for the fix soon ?
Thanks.
@sakkeerhussain Can you tell me, how do you fix it?
@Christ9038 I was added my models name in manifest with AA_Model tag. Even though Model names are correct the path to the model classes where not correct. I just corrected that and solved my issue.
@sakkeerhussain It solved my issue! Thank you so much.
@Christ9038 Great to here this from you.
Thanks, Sakkeer Hussain
On 6 April 2016 at 19:48, Christ9038 [email protected] wrote:
@sakkeerhussain https://github.com/sakkeerhussain It solved my issue! Thank you so much.
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/pardom/ActiveAndroid/issues/461#issuecomment-206392810
Hi @sakkeerhussain do you mean something like this?
<meta-data android:name="AA_Model" android:value="ModelName"/>
The same happened with me when I upgraded to Android Studio 2.0 I think this happens if we use gradle 2.0 as build tools. My app is working fine with gradle 1.3 as build tools. Could someone confirm this?
Is it AA_Model or AA_MODELS ? I tried both of them but still its not working.. Upgraded to Android Studio 2.0
I have same problem with upgrade on 2.0. I've updated manifest like this:
<meta-data android:name="AA_DB_NAME" android:value="1.0.0.0.1" />
<meta-data android:name="AA_DB_VERSION" android:value="20" />
And it works
UPD: also i've changed back gradle version to 1.5
@strgen what a db name hehe. I re-installed android 1.5.1 and its working just like before. I think I will release the app for now and later will change to Realm since AA is discontinued.
@xahy, what database name in your opinion is right? :) I'm using it for test when you need clear db.
have same problem with upgrade on Android Studio 2.0. the sModelInfo is empty.
@sebastiandeutsch @xahy solved !
If your project have ModelAxx, ModelBxx, ModelCxx...
you can write at Manifest.xml just like:
<meta-data android:name="AA_MODELS" android:value="com.my.db.ModelAxx, com.my.db.ModelBxx, com.my.db.ModelCxx />
@xushaojie I tried that, and still it was showing the same error. I can install Studio 2.0 again and try that. Will post here if its working.
@strgen 🤓
@xahy contains all models? check code again.
@soygustavo like this
include full path to your model classes.
@sakkeerhussain It resolves the issue but slows down the startup of my app a lot. Another solution is to disable the Instant Run in Android Studio.
@xushaojie thanks your solution is work ! 💃
@sakkeerhussain thanks but now i have another error
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.myproject.dataStorage.Preference.getValue()' on a null object reference
android.database.sqlite.SQLiteException: no such table: Preferences (code 1): , while compiling: SELECT * FROM Preferences
any ideas?
UPDATE:
i fix it changing this
<meta-data android:name="AA_DB_VERSION" android:value="2" />
for this
<meta-data android:name="AA_DB_VERSION" android:value="3" />
Disable instant run will fix the problem. Have to ways to do this. One in preferences on android studio. and other way to change your gradle version to 2.0.0 (this also remove instant run)
i have solved my issue
if u r using ur own Application class than initialize ActiveAndroid in oncreate method
ActiveAndroid.initialize(this);
complete code
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ActiveAndroid.initialize(this);
}
}
thanks @xushaojie works for me
adding AA_MODELS to Manifest did solve this issue.
@pynixwang Can you give me an example of how you put the paths of your clases , i've tried something like "com.mypackage.models.db.ClassName1,com.mypackage.models.db.ClassName2"
I'm using Android studio 2.2.3, Instant run disabled, Gradle version 1.5.0.
Error: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.activeandroid.TableInfo.getTableName()' on a null object reference
@Gustavol95 just the class name contain package,but gradle version is 2.1.4。
@Gustavol95 try to upgrade your gradle version and enable instant run,if I disable instant run ,there is no issue,but install apk everytime is not acceptable,it is too slow.
gettting every time same error :
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.activeandroid.TableInfo.getIdName()' on a null object reference
@PratikPagada see my code.maybe useful.
try with this
add this code in AndroidManifest.xml
<meta-data
android:name="AA_DB_NAME"
android:value="MyDb.db"/>
<meta-data
android:name="AA_DB_VERSION"
android:value="1"/>
and this code into you application class
Configuration dbConfiguration = new Configuration.Builder(this)
.setDatabaseName("MyDb.db")
.addModelClass(User.class)
.addModelClass(Topic.class)
.addModelClass(Conference.class)
.create();
ActiveAndroid.initialize(dbConfiguration);
Hi @derohimat
Configuration dbConfiguration = new Configuration.Builder(this) --> in this line , Configuration which library. Not found application.
Disable Instant Run in AndroidStudio solved it
you must add the model into AndroidMenifest.xml,just like this :
<meta-data android:name="AA_MODELS" android:value="pakage.xxxModel, pakage.aaaModel,..."/>
it worked for me !
check the Manifest, if your Application class is add <application android:name=".AppConfig" .....
my Class is: public class AppConfig extends Application {
@Override
public void onCreate() {
super.onCreate();
ActiveAndroid.initialize(this);
}
}
please declare name in manifest.xml > name =".NameApplicaionClass" <application ... android:name=".YourApplicationNameHere" ...>
android:value="aplicativo.oneplace.Entidades.USUARIO_CHAT_AMIGO_MENSAGEM,aplicativo.oneplace.Entidades.AMIGOS_USUARIO_SQLITE"
this is not working for me,
just this model is working = USUARIO_CHAT_AMIGO_MENSAGEM
this = AMIGOS_USUARIO_SQLITE not working... its the same package
@lucazin
android:value="aplicativo.oneplace.Entidades.USUARIO_CHAT_AMIGO_MENSAGEM,aplicativo.oneplace.Entidades.AMIGOS_USUARIO_SQLITE"
check that this line is in a single line, I think it does not work in several lines
you should turn off InstanceRun .For me worked .
Unable to create service io.uxtesting.uxtester.service.FloatingViewService: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String io.uxtesting.uxtester.model.TokenResult.getAppName()' on a null object reference
can anyone help me figure out this error
I had the same problem when I changed the location of the model. Double check in AndroidManifest.xml if the