-5

All i am trying to do is setup a simple android "hello world" example, i have made no alteration to the java code or xml layout (none to xml at all in fact) beyond what has been prescribed through searching stackoverflow as a remedy to the problems i am experiencing: scr folder errors, "R cannot be resolved to a variable."

I have followed the advice to import mypackage.R rather than android.R and to clean the project, as well as to rebuild it, restart eclipse after clean, and everything related that i can find... when i follow the advice to clean the project eclipse erases "import local.example.Project1.R" and resets it to "android.R" or completely removes the import...

i'm throwing errors in the simplest example of "hello world," which should be good to go right out of the box and cannot find a resonable explanation as to why...

what am i missing?

if it helps anyone to figure out the problem i notice that the gen folder does not contain anything, though indications are that it should contain a autogenerated java file....

package local.example.Project1;


import local.example.Project1.R;
import android.app.Activity;
import android.os.Bundle;
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;
    }

}
Brad Larson
  • 170,088
  • 45
  • 397
  • 571
me_
  • 681
  • 1
  • 8
  • 18

4 Answers4

1

If there is nothing in your gen folder, you'd better clean your project and build it again, or restart eclipse. Check your ADT version whether it is out of date. You can also download the latest SDK bundle to verify your project.

yushulx
  • 11,695
  • 8
  • 37
  • 64
  • the adt version is the latest available... i have literally downloaded and installed every available piece... updates indicate there is nothing left to install... i'm at a complete loss and yet i suspect you are on the right track... that the error most likely exists in a failure of the update process... – me_ Aug 08 '13 at 01:17
  • while it is not an answer as to what happened in the first place to cause an error in the simplest of applications... this is the closest to what i had to do to get it running... – me_ Aug 08 '13 at 01:34
0

Make sure you don't have any files, pictures, etc in your drawable or assets folder with capital letters, spaces, or dashes. Just use plane old lowercase. Also, try to clean your project. Go to project > clean. Then restart eclipse. Hope this helps. Also eclipse won't reconize any changes in XML files without saving first. Make sure to save after you add a button, ect.

NightSkyCode
  • 1,141
  • 2
  • 16
  • 33
  • i have not made any changes to the xml resource files... the only thing contained there is the stock icon which is labeled ic_launcher.png... the answer fails to explain why there would be an error in the src folder, or a failure to properly complile the simplest of applications downloadable as an example of android programming from the android developer site... – me_ Aug 08 '13 at 11:51
0

I can see that Clean - Build - Restart Eclipse is not working for you. Please see this answer, this might help you.

Community
  • 1
  • 1
CMA
  • 2,758
  • 5
  • 28
  • 40
0

If Eclipse couldnt generate the "gen" files which means there are something wrong with the xml files(layout for most of the cases). Check it again, fix it, clean and rebuild the project, it should work. Hope this helps

user2652394
  • 1,686
  • 1
  • 13
  • 15
  • it seems unreasonable that there should be something wrong with the "hello world" example, such as a poorly formatted xml file downloadable from the android developer site--this fails to explain why there would be an error in the source code folder or a failure to autogenerate java code in the gen folder... – me_ Aug 08 '13 at 11:47