need help changing my package name in eclipse

26,276

Solution 1

Step for changing package name using eclipse.

1- Right click on project .

2- Choose Android Tools.

3- Choose Rename application package

4- Type new application name then press OK.

Solution 2

In Eclipse, expand the tree for your app. Let's say it's called "Test".

Then expand the src as well,

then right click on com.example.test, click "Refactor", click "Rename", then type in your new name and click "OK".

Then double click on AndroidManifest.xml, and then just change the package="com.example.test" to package="com.what.you.want.it.to.be"

Hold control, shift, and click 'S'. Then it will ask "The package definition has changed...."

Answer "Yes".

Then left click on your project, the outermost part of the tree, then click on 'Project' at the top, then click 'Clean'.

Then re-test your app to make sure there were no errors, then upload it.

Solution 3

Here are the steps I followed to rename my package structure in my android app.

  1. Sort your package explorer to use hierarchical structure
    • In package explorer perspective click the down arrow. Select Package Presentation > Hierarchical
  2. Rename your package.
    • Right click on the level at which you want all below packages to be renamed
    • Select Refactor > Rename...
    • Enter the new package name. Make sure all the check boxes are checked especially "Rename sub packages"
    • Follow the rest of the wizard to change your classes packages
  3. Review your manifest file to see if it has been messed up as part of the rename. Especially check the package attribute of your application.
    • Compare with your HEAD revision from your source control repo by Right click > Compare With > HEAD Revision
  4. Clean your project
    • Project > Clean..
    • Check your project
    • Click OK
  5. Debug your project and accept the new package name
    • Right click on project > Debug As > Android Application
    • In Dialog box that says "The package definition has changed...." click Yes
    • Your references to the R class in your *.java files may be wrong now. You will need to fix these.

Solution 4

Got the same problem. I forgot to redefine package in Manifest file

Also remember to change package in your *.java files (on top of txt file)

Solution 5

its very easy if you follow the given instructions as follows http://movivations.wordpress.com/2012/04/27/change-package-name-in-android-motodev-eclipse/ Change Package Name in Android (Motodev / Eclipse) Changing your project package in Motodev Studio or Eclipse is always tricky and takes time to master. We’ll continue with our previous example of Re-ordering a list and modify its package name. The package name we used in this project was “com.movivation.reorderingdemo”. Let’s start Motodev Studio for Android 3.1 and begin this journey.

Now, we’ll be changing it to look like “com.movivationlabs.reorderingdemo”.

To change the name of your package, right click on package name, then select “Refactor” -> “Rename” as shown in the above image. After clicking “Rename”, you’ll see a window that resembles like this :

After changing the package, this window will look like :

On clicking the “OK” button on this dialog, Motodev Studio for Android processes your requirement to change the package name. The process takes a minute second to complete and you can see the changes here :

The first step of changing the package name is now completed. The next step is to change the package name using Android Tools found in the IDE. Right-click the “Project Name” in Project Explorer window, then click on “Android Tools” and at last click on “Rename Application Package”.

On clicking that menu item, opens another dialog asking for new package name:

The same dialog after changing the package name, the dialog looks like:

On affirming the changes, the IDE shows a very informative, line-by-line view of all the files that will be changed, and asks for final confirmation:

Clicking the “Finish” button starts the making the changes in all the mentioned files and finally the IDE asks for us to update the launch configuration:

This concludes the second step in changing the package. Now, all the files such as java source codes and Android manifest will be containing the newly proposed package. Look at the manifest file:

Our Re-ordering demo project was very small project with only one activity and a layout and that layout too, didn’t have any custom controls or UI controls that we extend in our project. The problem with Motodev and, in turn, Eclipse is that if we were to extend a UI control object, then the respective IDE won’t be able to modify the package name in the extended UI control object. Below is the extended ImageView control named “TouchImageView”:

This control is not used in our project, I’ve shown this control only to make you understand that we need to modify package names for any custom control we use. This is the final step in changing the package name of an Android project. In summary, • Refactor-rename the android package name. • Rename the package name using Android Tools. • Manually change the package in Android manifest or any other custom controls, styles, themes you’ve used in your project, if not changed otherwise. That concludes the tutorial for today. Hope it is useful to all the Android-ers!

Share:
26,276
user827304
Author by

user827304

Updated on November 04, 2021

Comments

  • user827304
    user827304 over 2 years

    so my package name is com.soundboard right now.

    obviously this name is taken...I am having trouble changing it throughout the package name.

    I checked a few posts here and did the refactor > rename and changed it to a more original name. When I tried to upload the new .apk I got the same message that the package name has been taken.

    When I change the package="com.soundboard" line in the manifest to something else I get errors all throughout all the other pages (.javas) when I save.

  • MSpeed
    MSpeed almost 11 years
    Also, make sure that no XML elements reference any classes with the old package name. Fragments especially.
  • Rob van den Berg
    Rob van den Berg almost 11 years
    Works! As mentioned, in step 5 I had to change some import references to R. and in step 3 adjust some Manifest references.
  • Deqing
    Deqing over 10 years
    Looks like steps are not the same in current version of Eclipse.