Tanvir
Tanvir

Reputation: 1683

Android Studio Change Project Name / Root Directory Name

How to change the name of a project's root directory in Android Studio 0.9.9. I read the other solution here but nothing works for me. I can change/refactor the package name but not the name of the root directory. I found another solution here, which is to change the name in .idea/.name file, which didn't work. After I changed name, I tried cleaning, rebuilding etc. but nothing reflected the changes in Android Studio. There is no REFACTOR option for "PROJECT NAME / ROOT DIRECTORY NAME", many people here confused the module name with project name / root directory name.

Upvotes: 43

Views: 78595

Answers (11)

hata
hata

Reputation: 12513

I have already up-voted to @Gorcyn's answer. However, it became a bit old info. So I try to update based on my own experience with Android Studio from 4.1.3 to Arctic Fox:

  1. Rename the project root directory name.
  2. Update the rootProject.name parameter in the project root settings.gradle file.
  3. Update fileurl and filepath attributes in the .idea/modules.xml file.
  4. Rename each .iml filename under the .idea/modules (or project root) directory to correspond to the updated fileurl and filepath.
  5. Update the external.linked.project.id attribute or the external.system.module.group attribute in each .iml file renamed above.
  6. (Open an Existing Project)

Upvotes: 0

Habib Rajpoot
Habib Rajpoot

Reputation: 1

My solution is:

  • close android studio
  • delete folders .gradel and .idea
  • then re open the project

Upvotes: -1

Gorcyn
Gorcyn

Reputation: 2817

Basically you can by changing the project's folder name and reopening it.

It is also recommended to change the name of the project in the Android Studio project structure by editing these files:

  • Change the project name in .idea/.name
  • Rename the [Name].iml file in the project root directory
  • Change the reference to this iml file in .idea\modules.xml
  • Change the rootProject.name in the project root settings.gradle

Upvotes: 71

Allexandre Vieira
Allexandre Vieira

Reputation: 61

To change the name of the project's root directory, the following worked for me: As the image bellow indicates, under the 'Project' tab,

  1. go to setting.gradle

  2. modify/include rootProject.name='put the name you want here'

  3. Then go to build -> clean project

  4. build -> rebuild project

enter image description here enter image description here

Upvotes: 0

androminor
androminor

Reputation: 405

My sure shot answer is : To refactor the root name

a) Rename the folder

b) then please go in settings.gradle > just write rootProject.name = 'new name'

Upvotes: 2

pableiros
pableiros

Reputation: 16062

  1. Right click on the root projects name.
  2. Refactor -> Rename
  3. Change the name.
  4. Rename directory -> Ok.
  5. Open settings.gradle and rename the :app from include ':app' with the new folder name including the :

Upvotes: 1

linuxfan
linuxfan

Reputation: 123

To avoid problems, use refactor: Change the left view from "Android" (where you see the files) to "Project". Right click on your project and select "Refactor/Copy". Now create your new project folder with windows explorer (otherwise you might get an IO Exception). After refactoring, be sure to select "Build/Clean Project" and then "Build/Make Project".

Upvotes: 0

Shady Mohamed Sherif
Shady Mohamed Sherif

Reputation: 15759

  1. File->Close project

  2. Change project root directory name

  3. Delete .iml files (by searching for them using windows search then deleting them)

  4. Delete .idea directory

  5. Open the project

Upvotes: 12

Von
Von

Reputation: 183

The easiest way I have found to do this is to copy the project and then change the root folder name on the copy. Then just open copy as a new project in Android Studio.

Upvotes: 1

Amit
Amit

Reputation: 577

  1. Close android studio

  2. Change project root directory name

  3. Open android studio

  4. Open the project(not from local history but by browsing to it)

Worked for me @ Studio 2.1.3

Upvotes: 24

Tanuj Verma
Tanuj Verma

Reputation: 398

This needs to be done manually. Can't understand why refactoring is not working.. Rename folder and then respective files

Upvotes: 1

Related Questions