android – App crash Attempt to invoke virtual method-ThrowExceptions

Exception or error:

After attempt to click on the button to go to the new activity my application crashed with this error

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.recyclerview.widget.RecyclerView.setLayoutManager(androidx.recyclerview.widget.RecyclerView$LayoutManager)' on a null object reference
    at com.example.myapplication.klienci.onCreate(

That’s my java class code in “klienci”

protected void onCreate(Bundle savedInstanceState) {
    Toolbar toolbar = findViewById(;
    NoteDatabase db = new NoteDatabase(this);
    notes = db.getNotes();
    recyclerView = findViewById(;
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    adapter = new Adapter(this,notes);

activity_klienci –

Thanks for help, regards.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *