How to change package name of Android Project in Eclipse?

122,658

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:

Alt text

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:

  1. Go and edit the manifest.
  2. Remove every old package name in the manifest.
  3. 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.
  4. Save the manifest.
  5. Then right click the package name inside the project.
  6. Select "Refactor".
  7. Select "Rename".
  8. Type the new package name.
  9. Select "update references".
  10. Press OK and you're done and watch out also what should be done to replace the new name.
  11. 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.

enter image description here

enter image description here

enter image description here

Share:
122,658
Dheepak
Author by

Dheepak

Updated on October 29, 2020

Comments

  • Dheepak
    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
    t0s about 12 years
    right click > Rename does not seems to be an option in Eclipse Helios.But F2 on package name works.
  • Alaa Eldin
    Alaa Eldin over 11 years
    Just don't forget the XML file, because you have to update it manually.
  • sheetal
    sheetal over 11 years
    u dont have to update the XML manulay..go to search >file >com.yourpackage >replace > new Package name
  • Austin
    Austin over 11 years
    This 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
    A-Live over 11 years
    Look for Rename command under Refactor if that is not at the root of the context menu.
  • SolessChong
    SolessChong almost 11 years
    Hey, 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
    Cheung over 10 years
    Package name is different to application name!
  • Kozuch
    Kozuch over 10 years
    I had to rename package name in AndroidManifest.xml manually. "Rename application package" in "Android tools" did not work.
  • CSchulz
    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
    LE SANG about 10 years
    Thanks! This way OK. The accept one make my App crash
  • Favas Kv
    Favas Kv about 9 years
    Wowww!! that's a perfect one.