Package name modification method for Android summarized by myself

Source: Internet
Author: User

The previous day, I took a task and said that I want to change the name of an existing project. The specific requirement is that the package name and global variable must be renamed.

Then I checked the information on the Internet and tried it. I found that it was useless and I always got an error in the last step. After combining several types of online materials, I have summarized an effective solution. Here I will explain it in text.


First, right-click the project whose name you want to modify and select Rename Application Package under Android Tools.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K13J7-0.jpg "title =" 1.png" alt = "wKioL1LfMF_gVebAAAWaqeln80Q482.jpg"/>

In the pop-up dialog box, you can see that this is a package name.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K1E25-1.jpg "title =" 2.png" alt = "wKiom1LfMJPRCasLAAOut8IJXCA364.jpg"/>

Add the name you want to modify and click OK.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K12X1-2.jpg "title =" 3.png" alt = "wKioL1LfMHvwL96kAAO1kMm6IaM958.jpg"/>

In the pop-up dialog box, we can see the file involved in modifying the package name automatically found by Eclipse. We can click AndroidManifest to see the comparison between the changes and the changes, it can be seen that ANdroidManifest has to be modified multiple times, because it is automatically modified, so it will not be what you want, and it is prone to errors, so we must remove the check mark before AndroidManifest.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K1IY-3.jpg "title =" 4.png" alt = "wKioL1LfMIahIH9nAAiHGxcfvcM940.jpg"/>

Remove the Ampersand before AndroidManifest and click Finish.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K14T0-4.jpg "title =" 5.png" alt = "wKiom1LfMLSx8eANAAkgU2ugvuQ183.jpg"/>

Step 2: Open the src folder, select the package name we want to change, press F2, or right-click Rename in refactor, and modify the package name. Only the first of the four matches must be selected, prevent problems. Then click Preview

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K11253-5.jpg "title =" 6.png" alt = "wKioL1LfMJyDdc66AAbDFSQlxw0737.jpg"/>


In the displayed dialog box, click Continue.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K11538-6.jpg "title =" 7.png" alt = "wKiom1LfMMqAKig1AAc7g5nymnY979.jpg"/>

In the displayed dialog box, remove the Ampersand before AndroidManifest to prevent errors in the AndroidManifest file. Modify all the package names that need to be modified according to this method.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K16395-7.jpg "title =" 8.png" alt = "wkiol1lfmlgtismmaaq1_indy5w307.jpg"/>


Step 3: After completing the first two steps, check whether there are any errors in the res file. If yes, immediately correct the errors.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K1A96-8.jpg "title =" 9.png" alt = "wKiom1LfMOLB8emhAAR0Zk5IaKo607.jpg"/>

In this case, because the package name is modified, app: textOff and app: test: On are not defined. We will remove it temporarily.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K110b-9.jpg "title =" 10.png" alt = "wKioL1LfMMuw_ZCuAAmYMyx6i-w610.jpg"/> 650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K14B2-10.jpg "title =" 11.png" alt = "wKiom1LfMPmSCBccAAlAUU16PsQ801.jpg"/>

Step 4: Open the AndroidManifest file and modify the package.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K125B-11.jpg "title =" 12.png" alt = "wKioL1LfMODiuRjkAAskjPC5ad8650.jpg"/>


Then we use Find and Replace to modify what we need to change.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K145V-12.jpg "title =" 13.png" alt = "wKiom1LfMReDyi6HAAugdoPFWBo917.jpg"/> 650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K150b-13.jpg "title =" 14.png" alt = "wKioL1LfMP7QHTlkAAv96bMVVHU333.jpg"/>


Step 5: After completing this step, we can see that the src package name and gen package name are consistent. Then, the undefined problem caused by incorrect gen folder name in the res file will be restored.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K1I33-14.jpg "title =" 15.png" alt = "wkiom1lfmsussovuw.me6fmrim088.jpg"/>

Step 6: Modify the class file or press F2 and select the first check mark.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K12032-15.jpg "title =" 16.png" alt = "wKioL1LfMRKxzE1wAAsAT8zGwtA790.jpg"/> 650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K11554-16.jpg "title =" 17.png" alt = "wKiom1LfMT7RoHUjAArDF4sdKgo879.jpg"/>

In this step, we can select the Ampersand before AndroidManifest, or you can change it by yourself.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/140207/222K113U-17.jpg "title =" 18.png" alt = "wkiol1lfmsssnwuaax_h_qzsze644.jpg"/> the last step is the global variables to be modified in the Find and Replace all class files.


Note: it may be difficult to compare this method with the online method, but this method is better than stable and error-free. It is suitable for the majority of cases and may not cause a large number of errors after modification.


This article is from the "HDDevTeam" blog, please be sure to keep this source http://hddev.blog.51cto.com/3365350/1353697

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.