Trouble compiling and running a basic program in eclipse for android

this is a real basic question, but I am having a frustrating time learning how to compile/run an android pong program from a website. The tutorial I am following is here -

I keep trying, and I am getting errors. I am new to android (but not programming) so I am having trouble identifying the problem.

Also the tutorial mentions layout.xml, but I do not see a layout.xml in eclipse, I see a main.xml, is that the same thing?

Attached is my screenshot with errors. Suggestions? Have I configured eclipse/java/android wrong? Is there a problem with the tutorial? I appreciate links to any other good game/graphic based starting tutorials you may have to offer.

Screenshot here


It looks like you need to add import statements to the classes you've copied from the tutorial. Double clicking on one of the errors (i.e. SurfaceHolder cannot be resolved to a type) should take you to it's place in the code. Hovering over where it says SurfaceHolder for a moment should pop-up something that will allow you to "Import 'SurfaceHolder' (android.view)". Try doing that and see if it starts getting rid of some of those errors.

Looks like you need to declare your package in your java files like so:

package com.mikey.pong;

public class GameState {

   //screen width and height
    final int _screenWidth = 300;
    final int _screenHeight = 420;

Looks like the tutorial assumed you would provide this.

and yes, your main.xml file is considered a layout, hence living in the layout dir.

It seems that you didn't import the classes contained in the android SDK to your project. In eclipse, press CTRL+SHIFT+O to invoke the import feature.

Need Your Help

Overriding web.xml filter configuration

spring java-ee cors web.xml

Is there any elegant way to override web.xml configuration and add something to cors.allowOrigin from a java class. My allowOrigin needs to be generated by code not hard coded.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.