need help changing my package name in eclipse
so my package name is com.soundboard right now.
obvious开发者_运维技巧ly 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.
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.
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.
Here are the steps I followed to rename my package structure in my android app.
- Sort your package explorer to use hierarchical structure
- In package explorer perspective click the down arrow. Select
Package Presentation > Hierarchical
- In package explorer perspective click the down arrow. Select
- 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
- 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
- Compare with your HEAD revision from your source control repo by
- Clean your project
Project > Clean..
- Check your project
- Click OK
- 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.
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)
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!
Looks like answers are quite different with different version of Eclipse.
In my version(Android Developer Tools Build: v22.0.5-757759
), I changed package name by following steps:
- Create a new package: In package explorer, right click 'src' under the project, choose 'new'/'Package'
- Move current package to this new package: right click on your java file and choose 'Refactor'/'Move'
Change the name of your app(How it shows on their device) Just change the value of app_name in the strings.xml file Change the Project folder name of your app 1- Right click on Main project 2- Select Refractor 3- Select Rename 4- Update to new name and press OK.
Change the package name of your app 1- Right click on project . 2- Choose Android Tools. 3- Choose Rename application package 4- Type new application name then press OK.
精彩评论