Renaming modules in Android Studio?

前端 未结 9 2517
闹比i
闹比i 2020-12-12 18:05

I picked the wrong name of a specific module which I imported to the Gradle project in Android Studio.

\"\"

9条回答
  •  一生所求
    2020-12-12 18:40

    As of Android Studio 3.4.1

    Rename module

    1. In Project window, right-click module and select Refactor > Rename
    2. Choose Rename module and press OK
    3. Enter new module name and press OK
    4. Important 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

    1. In Project window, right-click desired package and select Refactor > Rename
    2. If there are other src sets with same package name (test or androidTest), a dialog will ask if you want to rename them as well. If so, select Rename package
    3. Enter new package name and press Refactor
    4. Select Do Refactor in the Refactoring Preview

    Tip: Select File > Invalidate Caches / Restart to fix any unresolved resource references caused by renaming a module.

提交回复
热议问题