Rename package in Android Studio

0 votes
How do you rename packages in the new IDE Android Studio, based on IntelliJ IDEA? Is there automatic refactoring included?

I want to do bulk refactoring, but need help in doing so. I worked two years with Eclipse and in Eclipse it's a one-click operation.
Feb 23 in Others by Soham
• 8,730 points
544 views

1 answer to this question.

0 votes

In Android Studio, you can do this: For example, if you want to change com.example.app to my.awesome.game, then:

  1. In your Project pane, click on the little gear icon ( Gears icon )

  2. Uncheck the Compact Empty Middle Packages option
    Compact Empty Middle Packages

  3. Your package directory will now be broken up into individual directories

  4. Individually select each directory you want to rename, and:

  • Right-click it

  • Select Refactor

  • Click on Rename

  • In the pop-up dialog, click on Rename Package instead of Rename Directory

  • Enter the new name and hit Refactor

  • Click Do Refactor in the bottom

  • Allow a minute to let Android Studio update all changes

  • Note: When renaming com in Android Studio, it might give a warning. In such case, select Rename All
    Enter image description here

  1. Now open your Gradle Build File (build.gradle - Usually app or mobile). Update the applicationId in the defaultConfig to your new Package Name and Sync Gradle, if it hasn't already been updated automatically:
    Refactor Directories

  2. You may need to change the package= attribute in your manifest.

  3. Clean and Rebuild.
    Clean and Rebuild

  4. This should help you with your doubt. 

answered Feb 23 by Aditya
• 7,280 points

Related Questions In Others

0 votes
1 answer

Error: IllegalArgumentException: Unable to locate adb in Android Studio v2.3

when you try to move an Android project ...READ MORE

answered Dec 16, 2020 in Others by Gitika
• 65,850 points
1,651 views
0 votes
1 answer

Unable to detect adb version, adb output in Android Studio 3.3.2

To avoid this ERROR, start with changing ...READ MORE

answered Feb 11 in Others by Soham
• 8,730 points
259 views
0 votes
0 answers
0 votes
1 answer

How to install http package in Flutter?

Hi@akhtar, HTTP package contains a set of high-level ...READ MORE

answered Jul 30, 2020 in Others by MD
• 95,340 points
1,075 views
0 votes
1 answer

I want to restrict the opening of Browser on URL Click

You can call it as a web ...READ MORE

answered Aug 7, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
1,970 views
0 votes
1 answer

How can Blockchain be implemented for android development?

Essentially you need to understand what is ...READ MORE

answered Aug 10, 2018 in Blockchain by Johnathon
• 9,090 points
608 views
0 votes
1 answer

What is the future of flutter?

Hi@MD, Flutter is a rather new cross-platform framework ...READ MORE

answered Jul 17, 2020 in Others by akhtar
• 38,240 points
337 views
0 votes
1 answer

What is Flutter?

Hi@akhtar, Flutter is an app SDK for building ...READ MORE

answered Jul 17, 2020 in Others by MD
• 95,340 points
472 views
0 votes
1 answer

How to get current time and date in Android

In order to get the current date ...READ MORE

answered Feb 23 in Others by Aditya
• 7,280 points
89 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP