Reputation: 511
How to rename root module in android studio? I have tried (right click the module then click refactor then click rename) but I got warning "can't rename root module"
Upvotes: 46
Views: 41929
Reputation: 625
Change in settings.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
rootProject.name = "project_name" // change this
include ':app'
Upvotes: 1
Reputation: 1331
I pressed Ctrl+Shift+F to search my current root module name and found the name to be in the settings.gradle
file as rootProject.name=...
. I renamed it and synced the project (File -> Sync Project with Gradle Files) and the root module name was updated.
Upvotes: 102
Reputation: 339
In root of your project open setting.gradle and change rootProject.name='YOUR NEW NAME'
then close and restart android studio
Upvotes: 24
Reputation: 412
Video tutorial: https://youtu.be/7aQjiae2doU
com.example.[NewFileName]
in path:
app>java>com.example.[OldFileName]
<string name="app_name”>[NewFileName]</string>
in path:
app>res>values>strings.xml
applicationId "com.example.[NewFileName]”
in path:
Gradle Scripts>build.gradle (Module: app)
rootProject.name='[NewFileName]'
in path:
Gradle Scripts>build.gradle (Project Settings)
Sync now
prompt[NewFileName]
outside Android Studio Build>Rebuild Project
Upvotes: 4
Reputation: 71
This is tested for a pure Java projects (without any C/C++ code):
Upvotes: 4
Reputation: 3205
Close the project. (File > Close)
Rename the root folder of the project.
At the welcome screen "Open an existing Android Studio project" and provide the new path.
On your link that's the second answer or see also here.
Upvotes: 4
Reputation: 994
In your Project pane, click on the little gear icon ( setting icon at the right top)
Uncheck / De-select the Compact Empty Middle Packages option
Your package directory will now be broken up in individual directories 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
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
Upvotes: 2