j256 / ormlite-android

ORMLite Android functionality used in conjunction with ormlite-core
http://ormlite.com/
ISC License
1.59k stars 367 forks source link

Attempt to invoke interface method 'int com.j256.ormlite.dao.Dao.create' #66

Closed mostafaolyai closed 6 years ago

mostafaolyai commented 8 years ago

hi i used this library and released very well but when i want to save db this error appear Attempt to invoke interface method 'int com.j256.ormlite.dao.Dao.create' plz help me :(

j256 commented 8 years ago

Can you post the full exception?

mostafaolyai commented 8 years ago

06-14 05:01:22.189 1668-1668/com.example.smo_2020.hesabdar E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.smo_2020.hesabdar, PID:1668 java.lang.NullPointerException: Attempt to invoke interface method 'int com.j256.ormlite.dao.Dao.create(java.lang.Object)' on a null object reference at com.example.smo_2020.hesabdar.Activity_MainF$12.onClick(Unknown Source) at android.view.View.performClick(View.java:4756) at android.view.View$PerformClick.run(View.java:19749) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

j256 commented 8 years ago

I have no idea what is going on here. Are you using some sort of proxy or something?

koooooooooo commented 7 years ago

It sometimes happens when I call DB from Android Sticky Service. Maybe DB lost context in some way?...

FATAL EXCEPTION: Timer-0 Process: com.secret.monitoring.debug, PID: 2975 java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object com.j256.ormlite.field.FieldConverter.resultToJava(com.j256.ormlite.field.FieldType, com.j256.ormlite.support.DatabaseResults, int)' on a null object reference at com.j256.ormlite.field.FieldType.resultToJava(FieldType.java:819) at com.j256.ormlite.stmt.mapped.BaseMappedQuery.mapRow(BaseMappedQuery.java:60) at com.j256.ormlite.android.AndroidDatabaseConnection.queryForOne(AndroidDatabaseConnection.java:196) at com.j256.ormlite.stmt.mapped.MappedQueryForId.execute(MappedQueryForId.java:38) at com.j256.ormlite.field.FieldType.assignField(FieldType.java:558) at com.j256.ormlite.stmt.mapped.BaseMappedQuery.mapRow(BaseMappedQuery.java:71) at com.j256.ormlite.android.AndroidDatabaseConnection.queryForOne(AndroidDatabaseConnection.java:196) at com.j256.ormlite.stmt.mapped.MappedQueryForId.execute(MappedQueryForId.java:38) at com.j256.ormlite.stmt.StatementExecutor.queryForId(StatementExecutor.java:85) at com.j256.ormlite.dao.BaseDaoImpl.queryForId(BaseDaoImpl.java:223) at com.secret.monitoring.services.TravelService$UpdateNotification.run(TravelService.java:35) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505)

iman2420 commented 6 years ago

I have the same problem. Have you found a solution?

j256 commented 6 years ago

Although the exceptions are the same I'm not sure the issues are the same. In terms of the dao.create(...), it looks like you have an uninitialized dao field. That doesn't look like a ORMlite issue.

j256 commented 6 years ago

In terms of you error @koooooooooo, it looks like an internal field is null that should never be able to be null. Any chance the dao is being used before it is ruling initialized? An up-to-date line number or ormlite version number would be good to help locate the issue. Sorry I can't be more helpful. Open a new issue if you have more info.