Rename package in Android Studio

后端 未结 30 1913
深忆病人
深忆病人 2020-11-21 05:21

How do you rename packages in the new IDE Android Studio, based on IntelliJ IDEA?

Is there an automatic refactoring included?

I want to make bulk refactorin

30条回答
  •  一向
    一向 (楼主)
    2020-11-21 05:56

    The approach used by me for renaming the package name is simple as follows:-

    Step 1 : Select the Project option from left menu of Android Studio

    Step 2 : Right click on java and add a new package and set the desired package name

    Step 3 : Enter you new packagename

    Step 4 :Copy all the files from your old package and paste in the new package

    Step 5 :Rename the package name in manifest file

    Step 6 :Rename the package name in build.gradle file

    Step 7 :Then right click the old package and delete it with all its data, and delete that directory as well

    Step 8 :Then Rebuild your project

    Step 9 :Then you will find some errors of old import packagename in your project Select the old package name in any file and press CTRL + Shift + R , and enter you new package name in replace box, then press find

    Step 10 :Then a popup appears like below and select All files option from it

    Step 11 :Rebuild your project again, bingo your project packagename has been changed :)

提交回复
热议问题