Skip to content
Advertisement

Unable start activity, FATAL EXCEPTION: main [closed]

How can I solve this type of problem? The problem is in setOnClickListener which gives me a NullPointerException. If you need anything else let me know.

This is the error in Log:

JavaScript
JavaScript

Advertisement

Answer

Your problem originate from your ClickListener, here is the problem :

JavaScript

Disclaimer : without your layouts I can’t tell you for sure what is in cause, but stacktrace is pretty clear, clicklistener cannot be called on null value

Edit

First, you don’t have any View with id ‘home’ as declared in your mainActivity. So I suppose (as your code confirms, var is a CardView) you intended to use cardview as (sort of) a button. So you have to replace by this code :

JavaScript

Now it should work when you click on your Trovamico Cardview (from HomeActivity

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement