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.
Just get Far Manager and search through for the old name. Then manually (in Far Manager) replace everywhere. Sadly, this is the only method that works in 100% of the possible cases.
I had big trouble with this too.
I renamed the project and the package via refactoring, but it rendered the app useless. I renamed it back to the original and used the Android tools to rename the package and this worked, but my package folder and classes had the old name.
I then refactored the package folder. Now the app wouldn't run. My manifest was a mess. It doubled up my launcher name for example,
com.ronguilmet.app/com.ronguilmet.com.class. I fixed that, and I had to manually edit all activities.
Renaming an Application- The Complete Guide
**A) for changing Just the application name (App name which is displayed below icon) in the Manifest.xml file, in <application tag, android:label="YourAppName" then do the same in All the <activity Tags B) For changing EVERYTHING (folder names, Package names, Refrences,app name, etc.) *1) Renaming package names in gen folder and manifest.xml Right Click on Your project Android tools- Rename Application Package *2) Renaming package names in src folder Expand src folder, Click on package (Single click) Press Alt+Shift+R Check Update references and Rename subpackages 3) Renaming the app's main Folder (Optional) click on the application's folder (Single click) then Press Alt+Shift+R 4) Renaming application name- Refer "A)"**
OK here's what I had to do:
Problem: I had a base project that I wanted to use as a starting point for several other projects that would be in the same workspace as the base project. The base project was already under GiT control in my own local repo. It was time to duplicate the base project, "MyBaseApp", to become the starting point for "MyKillerApp."
- I just duplicated the overall MyBaseApp directory as MyKillerApp and had the two directories side-by-side.
- I edited file MyKillerApp->.project and changed the name from MyBaseApp to MyKillerApp. (This was necessary for step 3 to work.)
- I opened Eclipse and did a File->Import of MyKillerApp (I left out some details about how to use the Import menu, but click around, you'll figure it out.)
- I right clicked on MyKillerApp in the package manager and chose Android Tools->Rename Application Package to MyKillerApp. I checked all the options for renaming except the last checkbox about non-java files.
- I highlighted src->com.myname.MyBaseApp in the package manager and did an F2 to MyKillerApp. Then I did the same to a few classes including my opening activity class thing that goes into your AndroidManifest.xml file.
- I had to update a few function call names but the compiler pointed them out to me handily.
Thus I had a new project derived from a base project with no nomenclature left over from the base project and it was in its own local GiT repo.
Following worked for me in eclipse:
Go to AndroidManifest, search and replace old package name with new one and update everything when saving. Go to your root project package then press F2, write new name, and check Update References and Rename subpackages check boxes. After this everything was red in project (complaining about R import for every java file) because it wasn't changing closing tag of my custom view-s in layout xmls. After I changed these manually, everything was back to normal. That is it.
Press F2 and then rename it (or right click on the project and select
Rename). It changes wherever that package is declared in your project. It's automatically renamed all over.
Goto the Src folder of your Android project, and open the Java file.
Change the package
It gives you an error like this
The declared package "newName.android.widget" does not match the expected package "OLDName.android.widget.
To fix this problem, select Move filename.Java to Newname.android.widget and delete the old package folder.
Next step: Go to
AndroidManifest.xml and change
This worked perfectly for me (simple text replace):
Go to search -> file
Containing text: old pakage name
File name pattern: *
Replace: new package name
Now your project is full of errors.
Click your package in project explorer and press F2 (rename).
Fill in the new package name and check all checkmarks.
Wait for Eclipse to refresh. If there are still errors, clean all projects in the workspace:
Project -> Clean
None of this worked for me until I combined the two answers mentioned in this post.
Step 1: Right click on the project -> Select Android Tools -> Rename application Package. (This will change all the files in the gen folder and in AndroidManifest but will not change the package name in the src folder so I followed Step 2)
Step 2: Inside src folder Right Click your package name -> Refactor -> Rename -> Enter the new name that you entered in Step 1.
Just to make sure Check AndroidManifest if there is still the old package name and replace with the new one (in my case inside the "uses-permission" tag).
Then close the Eclipse and Reopen it. Uninstall the app from your device and install it again and everything should be working fine.
Hope this helps and saves your time.
Just right click on the project name and select Android tools and click Rename Application Package name and rename it. It's only for Android projects.
To change the app name when in Android, go to
res/values/strings.xml and change
app_name to what you want.
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.
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
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.
- How to change package name of Android Project in Eclipse?
- eclipse / android project - file encoding issue while change package name
- How to fix issue when I import Android project to Eclipse I get package name instead project name?
- How to properly change the package name in AndroidManifest.xml (e.g. in project zxing/barcodescanner)
- how to change a file name in Android Eclipse development
- Import eclipse project with other package name ? - Eclipse / Android
- How to change android activity in Eclipse cross-platform Libgdx project
- How to change minSDK Version in Eclipse Android project (recurring errors when saving)
- How can I change the name of *.xml file in the eclipse IDE's project explorer with one of its element
- Android app project in eclipse has many package errors, how do I fix this?
- How to change an Eclipse default project into a Java project
- How to change JDK version for an Eclipse project
- How to change a package name in Eclipse?
- Android - copy existing project with a new name in Eclipse
- How do you import an Eclipse project into Android Studio now?
- How to create a child package inside a package in eclipse project explorer
- change the name of android project
- How to convert an Eclipse Android project to use Ant for build?
- How do I change in an eclipse web project the WebContent folder to something different?
- How to use Gradle to generate Eclipse and Intellij project files for Android projects
- How to change the background color for changed files in eclipse project explorer?
- How to remove native support from an Android Project in eclipse because eclipse is showing errors in jni?
- Eclipse - How to "Change package declaration to ...." across an entire project
- How do you compile an Android project into an .apk file in Eclipse without launching the emulator?
- How to import eclipse library project from github to android studio project?
- How to remove a dependency from my Android project in Eclipse
- Change default package from com.example for Eclipse Android projects
- How to change the Control+Space autocomplete shortcut keys in Eclipse for Android
- How to use Linked Files in Eclipse for PhoneGap project with Android
- How to create new android project in eclipse and share in local git repository?
More Query from same tag
- Synchronize Eclipse workspace automatically?
- Prevent WSDL generation from including certain fields
- Subversive and Subclipse both in eclipse at same time how to disable one or the other?
- Error while importing gradle project
- How can i resolve the error "Line 1: The type XX cannot be resolved. It is indirectly referenced from required .class files" in GWT?
- Maven and Android natures not playing nice together
- Hardcoded TextView and Needed String?
- Null Pointer Exception throws in getConnection()
- In eclipse how to create Override methods in super type?
- Receiving broadcast error for Bluetooth discovery - Error in onReceive() method that receives intents by startDiscovery() Method
- Android ClassNotFound
- eclipse content assist settings
- Eclipse Maven Spring: Server Error when I try to Run As Server (Tomcat 7)
- Eclipse or intelliJ IDEA for selenium webdriver (java)?
- Trying to synch Flex Builder/Eclipse project with SVN source tree
- Can Anyone tell me why my IFile always returns null?
- R.java auto generation problem
- Eclipse Kepler crashes when I open Marketplace
- Removing 1000s of comments in eclipse?
- How to get .java file path to my eclipse plugin
- how to set up MAT in eclipse SDK
- what is the easiest way to print an image on screen on java?
- How to update eclipse indigo to eclipse Luna?
- NoClassDefFoundError for Birt Class EngineException
- setting up ecipse neon EE for dynamic web
- Record user details who committed what in CVS even if user does not want to enter comment
- Only have JavaSE 1.7 JRE but wish to compile for 1.6
- How to fix error occuring while executing EValidator
- Robolectric: Window creation failed
- Why the ImageView class is not found?