0

I know there is a lot of info on this here. But I can't find the answer to my particular question.

I'm trying to rename a package that is currently like this:

com.example.app.name

and I want to rename it to

com.example.name

I know you have to do refactor rename and make sure you have 'compact empty middle packages' turned off but I'm only know how to rename them when they are three directories long i.e. com.example.name and not how to actually get rid of one of the directories. So how do I reduce it from being 4 to only 3?

Hope I explained this correctly.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Debuggler
  • 3
  • 3
  • 2
    Possible duplicate of [How do I rename the android package name?](http://stackoverflow.com/questions/6600329/how-do-i-rename-the-android-package-name) – zgc7009 Sep 22 '16 at 21:16
  • 1
    Assuming you don't have many classes, you could just move the files in the project view between the folders. – OneCricketeer Sep 22 '16 at 21:18
  • You might want to read [this](http://stackoverflow.com/questions/16804093/android-studio-rename-package), it's explained very nicely with pictures. – Ilijas Sahinovic Sep 23 '16 at 02:09
  • Instead of renaming package use build variant feature of android studio. – Keyur Thumar Mar 17 '17 at 04:25
  • 1
    Possible duplicate of [Android Studio Rename Package](http://stackoverflow.com/questions/16804093/android-studio-rename-package) – Bo Persson Mar 20 '17 at 20:35

2 Answers2

0

Refactor the package name in the manifest file. Make sure to hit the "Do Refactor" button in the Find window.

Also, you will need to edit the package name in the build.gradle file.

I think that's it.

0

Rename Package Android Studio com.example.app.name to com.example.name

Steps:

  1. Close/Unselect Compact Empty Middle Packag.
  2. Move all source from "name" to "app".
  3. Delete "name".
  4. Change "app" to "name". :D
Jessie
  • 2,319
  • 1
  • 17
  • 32