How to change package name of Android Project in Eclipse?
Solution 1
As usual, by pressing F2
on the package name, you can rename or change the package name, and also by right-clicking and then select Rename
option, you can change or rename the package name.
When you press F2, it will show you the dialog box as:
In this dialog, don't forget to check the "Update references" checkbox because by making "check" to this check-box, it will make changes to all the references of the package which are referred by other components of project.
Solution 2
This is a bug in the Eclipse Android tools.
To fix: Right click on the project, go to Android tools -> Rename application package.
And also check AndroidManifest.xml
if it updated correctly. In my case it didn't, and that should solve this problem.
Solution 3
None of these worked for me, they all introduced errors.
The following worked for me:
- Right click the project and select Android Tools >> Rename Application Package.
- Enter the new Package name
- Accept all the automatic changes it wants to make
- Say yes to update the launch configuration
Solution 4
One extremely important notice:
NEVER use a direct package names as in something similar to passing a string value containing the package name. Use the method getPackageName(). This will make the renaming dynamic. Do whatever to reach the method getPackageName().
In Eclipse Juno, the correct way of renaming is:
- Go and edit the manifest.
- Remove every old package name in the manifest.
- Put instead of the old package name, the new package name in every location inside the manifest. You might have classes (Activities that is) that need direct package name references.
- Save the manifest.
- Then right click the package name inside the project.
- Select "Refactor".
- Select "Rename".
- Type the new package name.
- Select "update references".
- Press OK and you're done and watch out also what should be done to replace the new name.
- Don't forget to also update the layout XML files with the new package name. You might have a custom View. Look for them.
Solution 5
Right click on your project name and select Android Tools , then click
Rename Application Package, then change your project name click OK and
click Finish.
Dheepak
Updated on October 29, 2020Comments
-
Dheepak over 3 years
I have an Android project created in Eclipse. I want to modify the package name and application of the project. How do I do that in Eclipse?
-
t0s about 12 yearsright click > Rename does not seems to be an option in Eclipse Helios.But
F2
on package name works. -
Alaa Eldin over 11 yearsJust don't forget the XML file, because you have to update it manually.
-
sheetal over 11 yearsu dont have to update the XML manulay..go to search >file >com.yourpackage >replace > new Package name
-
Austin over 11 yearsThis worked for me in the following way. It changed all files in gen folder and in AndroidManifest.xml. Then I went back to my package (in src folder) which hadn't changed. I redid Right Click -> Refactor -> Rename. Entered the new name and bingo. Done
-
A-Live over 11 yearsLook for
Rename
command underRefactor
if that is not at the root of the context menu. -
SolessChong almost 11 yearsHey, this is actually an android project so it won't compile like this! You must use Android Tools to rename package, as @vamsu says.
-
Cheung over 10 yearsPackage name is different to application name!
-
Kozuch over 10 yearsI had to rename package name in AndroidManifest.xml manually. "Rename application package" in "Android tools" did not work.
-
CSchulz about 10 years"Note: This doesn't seem to work in Eclipse 3.8, because the option to check "update references" wasn't there. Instead, I manually renamed the package name at the head of the classes, and in the xml files."
-
LE SANG about 10 yearsThanks! This way OK. The accept one make my App crash
-
Favas Kv about 9 yearsWowww!! that's a perfect one.