Renaming the package that R.java is generated in Renaming the package that R.java is generated in android android

Renaming the package that R.java is generated in


Right click your project, then Android Tools -> Rename Application Name:

enter image description here

Or, if you want to do it manually, go to your manifest file, change the package name, and make a Project Clean.


Check the AndroidManifest.xml, there's a package attribute on the <manifest> top-level element. That is where R.java is generated and you should be careful renaming it.


For those who attempt to manually change it, the statements that the R.java file is linked is correct. If you simply change it in the manifest, you will get a long sequence of "R cannot be resolved" errors throughout your java files that reference resources. To correct that you'll need to add an import for the R class in each of those files.

So if you had your package originally as: "com.mycomp.myapp.android" and changed it to "com.mynewcomp.myapp.android" you would need to go into each java class file and add:

import com.mynewcomp.myapp.android.R;

If you run the originally suggested rename command on the project this is done for you automatically.