Jack welch
Jack welch

Reputation: 1707

Problems with R in eclipse for android

I am writting a class in eclipse for android and i am having problems with my R.layout.main.

public class createplayer extends Activity{

    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.createplayer);//problems with R

    }
}

Upvotes: 1

Views: 611

Answers (3)

Rawr
Rawr

Reputation: 2224

  1. Like user717572 said. Try cleaning your project, sometimes things get messed up
  2. Check your imports; remove import android.R, the problem is that Eclipse is looking for Android.R.layout.main instead of com.your.package.R.layout.main. So another alternative to is to replace import android.R with import com.your.package.R if removing it doesn't solve your problems.
  3. And then of course make sure you have a layout called createplayer

Upvotes: 2

Shellum
Shellum

Reputation: 3179

What kind of problems are you having?

Cleaning your project may do the trick.

Otherwise, if R is not being created, there is probably an aapt error in parsing your xml files. You can manually run:

aapt package -m -v -J <path to your gen folder>/gen -M <path to your manifest>/AndroidManifest.xml -S <path to your res folder>/res -I <path to your android-sdk>/platforms/android-5/android.jar

This will list out where the problems are if your IDE is not telling you.

Upvotes: 0

user717572
user717572

Reputation: 3652

Check your imports for import android.R and remove it. And otherwise try project->clean.

Upvotes: 0

Related Questions