Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Simple Android App (retired 2014) Pretty Little Things Adding Sounds

NullPointerException in animateCrystalBall()

I'm having difficulties with code that previously worked just fine and that I've not changed! I assume the problem may lie elsewhere.

However, LogCat is giving me the following errors:

05-18 06:41:17.801: E/AndroidRuntime(1254): FATAL EXCEPTION: main 05-18 06:41:17.801: E/AndroidRuntime(1254): Process: uk.co.bigdogconsultants.crystalball, PID: 1254 05-18 06:41:17.801: E/AndroidRuntime(1254): java.lang.NullPointerException 05-18 06:41:17.801: E/AndroidRuntime(1254): at uk.co.bigdogconsultants.crystalball.MainActivity.animateCrystalBall(MainActivity.java:49) 05-18 06:41:17.801: E/AndroidRuntime(1254): at uk.co.bigdogconsultants.crystalball.MainActivity.access$2(MainActivity.java:47) 05-18 06:41:17.801: E/AndroidRuntime(1254): at uk.co.bigdogconsultants.crystalball.MainActivity$1.onClick(MainActivity.java:40)

Line 40 is the call to the animateCrystalBall method Line 47 is the declaration/definition of the method and Line 49 is


I can't see anything wrong with that. The


file is there unaltered so I'm not sure what is pointed at that is Null.

Any ideas?


And if I comment out the call to the method everything works fine just without the animation, obviously!

2 Answers

Anthony H
Anthony H
2,515 Points

Post your log cat file and source @ pastebin.com/ then we can look at the code/files you're have problems with ;)

This self-fixed somehow. I can't replicate the problem and the animation works fine!