I picked the wrong name of a specific module which I imported to the Gradle project in Android Studio.
In AndroidStudio 2.2.2 renaming the module alone via refactor/rename worked for me. (32-bit linux Mint)
The rename dialog presents two options: "directory" or "module" (radio buttons so mutually exclusive, at least in one pass). I wasn't sure which to pick so I ended here looking for an answer. One answer said "do both" as two steps, another answer said "do module, then directory" as two steps. So I chose "module" first. To my surprise that was all that was needed, both module and directory were changed. settings.gradle was updated by the refactor/rename in the one step as well.
"gradle synce" and "clean build" were also triggered. Upon build to my tablet, no complaint about the name change.
just adding this answer in case someone else with 2.2.2 or later is unsure which to pick. Also to re-iterate what others have said, back up your project first.
As of Android Studio 3.4.1
Rename module
Refactor > Rename
Rename module
and press OK
OK
settings.gradle
is updated automatically. However, you must manually update any build.gradle
dependencies to reflect new module name:dependencies {
// manually update this after renaming the module
implementation project(':newmodulename')
}
Rename package to reflect new module name
Refactor > Rename
test
or androidTest
), a dialog will ask if you want to rename them as well. If so, select Rename package
Refactor
Do Refactor
in the Refactoring PreviewTip: Select
File > Invalidate Caches / Restart
to fix any unresolved resource references caused by renaming a module.
In the project view on the left in Android Studio,