How can I quickly modify the project name and package name of Android Eclipse?

Source: Internet
Author: User

How can I quickly modify the project name and package name of Android Eclipse?

Modifying the project name/package name is also a common problem during development. For example, during the development process, we suddenly felt that the project name was inappropriate, or the root package name is not suitable. What should I do if I want to modify it?


As shown in the project, I want to change my project name, for example, change zzz to xxx, and change my root package com. example. change zzz name to com. byl. xxx. What should I do quickly and ensure that no error is reported in my code?

Next we will first change the package name:

You can change the name of a file by clicking a shortcut key and pressing win + F2. Some may do the following:


Can this meet your needs? The answer is no, because there is a sub-package below it, we can see the situation after this method is modified:


What should we do in the correct way? First, check the number of sub-packages under your root package and find the underlying sub-packages or files (refer to the first figure ):


Modify the z1 path, as shown in the following figure:


Next, modify the z2 and z3 package names in the same way:


Finally, modify the package name of MainActivity:


OK. At this time, we can see that the project has not reported any errors, but this is not complete, because the package name in our configuration list has not changed. If it remains the same, the work we just made is futile:


Some people have said that it is not very simple. I just changed it. Is that true? Let's take a look at the result after direct modification:


Why are all errors reported? The reason is very simple, because your R file path is still the original package path:


You may say this is easy to handle. I have changed the file one by one in the java file. Of course you can. If you have fewer files, you can, but more, should you change the number of dozens or even hundreds of times one by one? Is there any way to do this once and for all? Of course, first open the gen directory and modify the package name:


After confirmation (do not be afraid ):


Next, modify the package name in the configuration file:


Final result:


No error is reported!

Okay. How can I modify the project name after the package name is changed? Win + F2 directly? Haha, you will find that when you copy the project to another place, the project name is still the original, isn't it strange ?? You also need to perform the following operations to open the project folder, find the. project file, open it, modify the project name, and then right-click the refresh project in Eclipse:


All modifications are completed:



Although this does not have any technical knowledge, it is still useful for beginners or those who do not know how to modify the name of the project package. It also helps you avoid detours and save development time, now, let's go here ^!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.