The easiest way to modify the package name in Android Studio

Source: Internet
Author: User

Android Studio, we develop Android's weapon, since the launch was sought after by mobile developers, but along the way, we talked about him, full of excitement, but also slightly shy. With the release since the launch, and constantly improve the bug, but we still deeply stepped in, said more, a faint sadness began to emerge. Cut into the theme (today is to share an entry-essential trick, how to use Android studio to modify the package name!) ))

First let's introduce the directory structure of Android studio, so that each friend, in the process of modification to have better brain map guidance, but also as an introduction to the Android Studio directory, a bit of Doha.

Shows the most basic directory structure after we open the Android studio, it is also easy to be ignored by everyone. Here we first talk about the hierarchical relationship, according to my comprehensive search media, books, as well as from the understanding, Android Studio hierarchy (commonly known as directory structure), is such a link,Project----> (n) module, I will not do tree-like, I will tell the details, we listen carefully, in fact, the concept is still relatively simple, but because of a change in the form, many students, easy to confuse, Eclipse Project equivalent module, the argument is different, then simple point, project equivalent to a large file, And we do the root of the site a meaning, below a number of subdivision files, called module, which is our app. Next, let's start with the steps to switch the package name, the first step is to click on the package name under packages, see

Confined to space, only part of the section, find the package name, is generally the COM. file name. The final filename, such as Com.android_studio. First, then the above diagram, click on the rename in refactor, change the new name you want to see.

Enter a new name and click Refactor.

And then we get to the second step: Change the ApplicationID in the Build.gradle (module:app name) file

Step three: Clean and rebuild Project

We must have questions about why clean and rebuild, because many apps are already integrated, Multiple files refer to the package name (Com.example.administrator.myapplication, which is not changed before the name), to be all, note that all of the two words are changed to Com.example.administrator.myapplication _studio, you need clean and rebuild.

Fourth step: Turn off Android studio Restart, haha, done.

The last step: can have or can not

If you go through the above steps also wrong, according to my practice, pro-test n times, there is no problem, whether it is a newly installed app or good, sometimes, the IDE version is different, may effect different, according to the principle, after the above steps, the package name of each file will be automatically replaced, in case, then send on two strokes, First: Change mainifest inside the package value, change the name you changed, second, change R file (in the package), see the first picture, hey, here you know the usefulness of this file, R file hidden in this.

I am doing in the process of a little experience and method, here all dedicated to everyone, hope that we can find their own needs, and I will continue to serve you more development knowledge, but also very happy, can take advantage of this opportunity to my favorite blog park, share their own harvest, I hope the blog park More and Better, O (∩ _∩) o haha ~, pull away, Zhongshan College wireless class cock silk drifting over!!

The easiest way to modify the package name in Android Studio

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.