[Solved] Android app force closes when painting a ball?


I’m not sure why you’re defining a local variable b in your start() method since you’ve already defined one as a class member. The one you created in start() will be lost as soon as start() returns.

Also: the member object you create will be instantiated long before onCreate() is called. Is there enough context available when the Activity is created for Ball() to be created successfully? Without seeing the source code to Ball() we can’t tell.

Your logcat output indicates that the class for Ball was not found. Did you write it? Did you put it in the right directory where Eclipse could find it?

This question and your follow-ups seem to indicate that you’re extremely new to Android programming, and possibly new to Java. If you’re new to Java, I would think good and hard about trying to learn Android so soon. Android is not a programming environment for beginners.

That said, I suggest you start out by doing some of the tutorials to familiarize yourself with the system. Then, to write your own application, find a tutorial that most closely resembled what you’re trying to do, copy it, and start making modifications. I almost always start new projects by copying old projects. This way, you know that filesystem layout and so forth is probably correct to begin it.

Finally, at the bottom of your Eclipse window, you’ll see a tab labeled “Problems”. This can be very useful for finding out what’s gone wrong. In your case, the explanation to why Ball wasn’t found is likely to be there. And of course, check your Console and Logcat tabs as well.

solved Android app force closes when painting a ball?