Search code examples
androideclipser.java-file

Another R.Java file missing


Ive just joined StackOverflow because I just cant find any answers to my problem. :(

I have however found other threads on this, and none seem to fix it.. i have no idea why.

So basically, i am trying to make an android app, i start up a NEW project and already the R.Java is missing (causing major issues, and i can't even compile from it :( ), ive tried: import.android.R;, import.(packagename).R;, ive tried to "clean" it, and a bunch of other stuff. Literally everything i can think of.

What is going on, and how can I fix this?

 package com.nicco.compare;

 import android.os.Bundle;
 import android.app.Activity;
 import android.view.Menu;

  public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

  }

Solution

  • R.java is auto generated.

     1. Do you have a import statement like import android.R;. If so remove the import
    
     2. Do you have errors in your xml files. If so fix them
    
     3. Clean and build project.
    

    My guess your are importing android.R Remove this import statement(import android.R;). Clean and build you project. this should solve your problem.

    Right Click on project goto properties choose android on the left. Check you have the right version checked.

    Also look for the sdk version in manifest file

    enter image description here