How do you rename packages in the new IDE Android Studio, based on IntelliJ IDEA?
Is there an automatic refactoring included?
I want to make bulk refactorin
Place your cursor in the package name like shown below. Don't select it, just place it.
Then press Shift + F6 you will get a popup window as shown below select Rename package.
Enter your new name and select Refactor. (Note since my cursor is on "something", only something is renamed.)
That's it done.
This I believe what you are looking for is Refactor > Move. You can also press F6.
You will get two popups. Make sure you select rename package on both. After that you will get a pop up to place the new package name.
Please note that if your package name is, for example, com.example.android.projectname then this will let you change com.example.android to something else.
One more thing, this will update the applicationId in your build.gradle as well. Just make sure that the checkboxes for "search in comments and strings" and "search for text occurrences" are both checked for it to work.
Select the package that will be refactored. Refactor → Move → "Move xxx to new package".
Packages serve two purposes. One is to uniquely identify your app in the Google Play Store. The other is to name the package for the R.java class
which is generated when you build your project. You can think of the first purpose as the external package and the second as the internal package. Assuming you want to change the external package so you can identify in the Play store, there's a convenient way to do this.
In Android Studio,
choose File -> Project Structure -> Choose your app's module -> Click on the
Flavors tab -> change the Application id.
Now, when you build your project, your APK and manifest will use this new package name.
Press Ctrl + Shift + R
Replace the old package with the new one.
Right click on the package name.
Refactor
> Rename
and rename to the new one
Updated answer: May 2015
OK I have been struggling with cloning & renaming projects in Android Studio, but finally I achieved it. Here are the steps to follow:
That's it...