question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Number.longValue()' on a null object reference

See original GitHub issue

DBFlow Version: 4.1.1 Issue Kind (Bug, Question, Feature): Bug Description: after update from 4.0.5 to 4.1.1 i have this error java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Number.longValue()' on a null object reference 09-05 14:50:01.977 3481-3481/* W/System.err: at com.raizlabs.android.dbflow.structure.ModelAdapter.hasAutoIncrement(ModelAdapter.java:316) 09-05 14:50:01.978 3481-3481/* W/System.err: at com.raizlabs.android.dbflow.sql.saveable.AutoIncrementModelSaver.insert(AutoIncrementModelSaver.java:49) 09-05 14:50:01.978 3481-3481/* W/System.err: at com.raizlabs.android.dbflow.sql.saveable.ModelSaver.save(ModelSaver.java:51) 09-05 14:50:01.978 3481-3481/* W/System.err: at com.raizlabs.android.dbflow.sql.saveable.ModelSaver.save(ModelSaver.java:35) 09-05 14:50:01.978 3481-3481/* W/System.err: at com.raizlabs.android.dbflow.structure.ModelAdapter.save(ModelAdapter.java:190) 09-05 14:50:01.978 3481-3481/* W/System.err: at com.raizlabs.android.dbflow.structure.BaseModel.save(BaseModel.java:68) and field with @ForeignKey(saveForeignKeyModel = true) and autoincrement primary key. In 4.0.5 all working fine. In patch-notes i can`t find any changes about it behavior

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
xanscalecommented, Oct 6, 2017

or simply…

@PrimaryKey
private long id;
1reaction
danvwellscommented, Sep 5, 2017

I noticed this recently too. If you initialize your auto incrementing primary key to some value, say 0, I think that works around this. Something like this

@PrimaryKey
private Long id = 0;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Attempt to invoke virtual method 'long java.lang.Long ...
debug your code / print logs and make sure you not getting null value of getTimestamp and try this it will work. String...
Read more >
Attempt to invoke virtual method 'long java.lang.Long ... - GitHub
java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference #456.
Read more >
Attempt to invoke virtual method 'long java.lang.Long ...
NullPointerException : Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference in android native app.
Read more >
Fixed Error android error attempt to invoke virtual method
Need Help or Code Support? Feel Free To Contact Us Here http://www.aaviskar.com/support.phpThis video is about Fixed Error android error ...
Read more >
Fixed Error android error attempt to invoke virtual method
... method | Null object reference This video is about Fixed Error android error attempt to invoke virtual method and resolved java. lang....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found