0

I have upgraded to android studio 2.0 last week, but now every time I run any app I get the following error messages in the logcat.

I have posted 2 screen shots below. The first one shows an app that was created when starting android studio with no code added by myself. The second image shows the logcat error message when the app is ran using the emulator.

Can someone please explain to me how I could try to fix this or reset/reinstall android studio without uninstalling the program???

Screenshot 1

Screenshot 2

tb08
  • 57
  • 1
  • 5

1 Answers1

0

If you are referring to the section of code that's highlighted, that's just a warning. If you hover the mouse over it, you will get a description of why Studio thinks it could be a problem.

Basically, there are new lint rules that know that the return code from findViewById() can return null, which means your fab reference may be null, and therefore you could be calling the method setOnClickListener() on a null object. This situation, of course, would actually crash your app, and this is what the warning is trying to prevent.

You can remove the warning simply by checking fab for null before calling methods on it.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • Thanks Doug, but in the question I was referring to the error in the logcat file (Screenshot 2 image). Before the 2.0 update I did not see these messages in the logcat. I have tried to google them but don't really understand others answers or suggestions as I'm new to android studio (currently creating my first android app) – tb08 Apr 14 '16 at 19:18