How to change package name of Android Project in E

2019-01-03 01:49发布

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?

16条回答
Lonely孤独者°
2楼-- · 2019-01-03 02:21

To change the app name when in Android, go to res/values/strings.xml and change app_name to what you want.

查看更多
孤傲高冷的网名
3楼-- · 2019-01-03 02:22

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.

查看更多
小情绪 Triste *
4楼-- · 2019-01-03 02:22

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."

Solution:

  1. I just duplicated the overall MyBaseApp directory as MyKillerApp and had the two directories side-by-side.
  2. I edited file MyKillerApp->.project and changed the name from MyBaseApp to MyKillerApp. (This was necessary for step 3 to work.)
  3. 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.)
  4. 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.
  5. 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.
  6. 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.

查看更多
霸刀☆藐视天下
5楼-- · 2019-01-03 02:23

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.

查看更多
老娘就宠你
6楼-- · 2019-01-03 02:24

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.

查看更多
劫难
7楼-- · 2019-01-03 02:28

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.

查看更多
登录 后发表回答