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,
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)
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
- Samsung Android device won't go in debug mode
- How to use libvlc for android for streaming live videos
- JUnit Test Suite and Ant Build "ClassNotFoundException"
- Loading pictures in eclipse
- Android Manifest- intent filter and activity
- What happens if I modify class in project while application is still running?
- Could not remove buildType in AndroidStudio 1.0 RC
- Eclipse PDT
- Eclipse Oxygen plug-in Missing Constraint: Import-Package
- Android Eclipse xml editor autocomplete on Mac OX not working
- Android AdMob without XML
- Why is Eclipse Juno 4.2 running "JPA Java Change Event Handler" processes?
- Eclipse "Java heap space" error, Eclipse not responding
- What are the correct jar files to import to Eclipse to write MapReduce programs with the new APIs?
- How to store data to dynamic fields in openerp?
- Showing CustomViews properly in Graphical Layout of android xml
- How can I configure eclipse to run my java program with extra arguments?
- Starting WebLogic 9.2 Managed Server in debug mode in Eclipse
- How solve these error using tomcat server in eclipse for deploy jsp page?
- Error on importing mahout using maven
- Ant move puts newline at the end of property
- How can I get(know) the menuid of a specific menu in eclipse?
- SVN update in eclipse every day
- How can I write data in local JSON file using jQuery?
- Eclipse: copying a warning to the clipboard
- Eclipse: "PHP Fatal error: Call to undefined function mysqli_connect()"
- Where does Eclipse store SSL keys?
- I need help with eclipse's configuration
- How can I format an entire source tree in Eclipse 3.4 (Ganymede)?
- How to declare an integer's value in system.out.println