Search code examples
androidr.java-file

manually modiffying r.java


I am working in android SDK(Eclipse) platform 2.2 and I have been running through some tutorials, and some of them say to just add files to existing folder, or add folders; with files inside them. At several points when I create a new folder and place a new file inside it, and code everything corectly R.java does not recognize the new folder, or even the new file(constants, buttons, strings, reference ids). several times now I have had to go in and manuallly alter R.java (adding classes, and constants) by hand.

So my question is multi-facited: does R.java not expect me to create new folders, and files, and in turn live inside the given folders and files (making multi activity application near-impossible)?

If I have to alter R.java by hand is there any specific consideration to naming and numbering(memory address) that I should follow?

Is there any way for me to get R.java to recongnize that a folder/file/class/constant even exists without having to brute force enter it?


Solution

  • Let me Guess you are using eclipse.

    It is all ways better to enable the option Build Automatically in Project->Build Automatically.

    When you face this problem( R file not generated automatically) follow the following steps.

    1.Right Click on the project and click "Close Unrelated Project"

    2.Refresh you current working projects and make sure you see all your new contents are there in the res folder.

    3.Now Uncheck Build Automatically and Click Build All from the project menu.

    4.Now clean the project.

    Hope your problem is solved now.