Monday, 7 March 2011

How to change the package of the applications - Android

In this post I showed how to change completely the name of the application. But if you want to change also the name of the package, you can do the follow: (I will show a example which I change the package called "oldPackage" to "newPackage")

1. Change the name of the package
1.1 Right click on src -> oldPackage and select Refactor -> Rename
1.2. Change the name of the package from "oldPackage" to "newPackage". Do not click on "OK" yet
1.3. Uncheck the option "Update references" and click on "OK"

2. Change the name in AndroidManifest.xml
2.1 Open AndroidManifest.xml file
2.2 In the tag <manifest> you will find the attribute called "package". Modify it from "oldPackage" to "newPackage"
2.3 Save the file. When it asked you "The package definition in the manifest changed. Do you want to update your Launch Configuration(s)?". Click on "Yes"

Android SDK will automatically regenerate the package. To check that everything went fine, check the new package in "gen" (Generated Java Files). It should appears there.

No comments:

Post a Comment