First, open the project directory by right-clicking on the project name and click at show in explorer option. Step 2: Close the android studio, and go to the window explorer of the project directory and rename the root folder with a new name.
Launch Android Studio, and click File > New > Import Project. Locate your project directory, click the build. gradle file you created above to select it, and then click OK to import your project.
Step 1: To rename package name in Android studio open your project in Android mode first as shown in the below image. Step 2: Now click on the setting gear icon and deselect Compact Middle Packages. Step 3: Now the packages folder is broken into parts as shown in the below image.
The steps in the link you specified should also work for Android Studio. Just make a copy (using a file manager) of the entire module folder and give it a new name. Now open it up and use Refactor -> Rename
(right click on the item you want to rename) to rename your module and package.
See this for details about refactoring in IntelliJ/Android Studio.
If you use Gradle - don't forget to change applicationId attribute in app/build.gradle file.
As free3dom pointed out, here's what should be done:
build.gradle
file to change the package name (you can use the file manager).AndroidManifest.xml
to change the package name.gradle sync
.That seems to work without any problems.
If you are using the newest version of Android Studio, you can let it assist you in this.
Note: I have tested this in Android Studio 3.0 only.
The procedure is as follows:
In the project view (this comes along with captures and structure on the left side of screen), select Project instead of Android.
The name of your project will be the top of the tree (alongside external libraries).
Select your project then go to Refactor -> Copy...
.
Android Studio will ask you the new name and where you want to copy the project. Provide the same.
After the copying is done, open your new project in Android Studio.
Packages will still be under the old project name.
That is the Java classes packages, application ID and everything else that was generated using the old package name.
We need to change that.
In the project view, select Android.
Open the java sub-directory and select the main package.
Then right click on it and go to Refactor
then Rename
.
Android Studio will give you a warning saying that multiple directories correspond to the package you are about to refactor.
Click on Rename package
and not Rename directory
.
After this step, your project is now completely under the new name.
Build -> Clean project
then Build -> Rebuild project
.This is a combination nt.bas's answer and step 9 of Civic's answer with visual examples because it took me a while to find out what was intended since I am new to Android Studio. It has been tested in Android Studio 3.2.1.
Open the project you want to clone in Android Studio. (In this example, the old project name was test5
and the new project name was test6
)
In the left file-overview pane, click: Project (where it might currently say android).
app.java/< your old project name>
(not the com.example.<your old project name>(androidTest)
one, not the com.example.<your old project name>(test)
one, just the blank one)
Open app/res/values/strings.xml and change name of the old project (e.g. test5) to the new name of the project in line:
<string name="app_name">test5</string>
Open Gradle scripts/build.gradle (Module:app) and change the line to the same line with your new project name:%fig4
applicationId "com.example.a.test5"
The purpose of this is so I can have a second version of my app which is ad supported in the app store.
Currently the best way to do it is without copying the project.
You can do it using diffent flavors in your build.gradle
file.
productFlavors {
flavor1 {
applicationId = "com.example.my.pkg.flavor1"
}
flavorAdSUpport {
applicationId = "com.example.my.pkg.flavor2"
}
}
In this way you have only a copy of the files and you can handle the difference easily.
I'm following these steps and it's been working so far:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With