Change domain android project

1

I need to change the domain of my android project.

Example:

When I created the project I put a fictitious domain: br.com.domain-x

Then when the project evolved, I registered a valid domain: br.com.domain-and

I need to make this change and I do not know which is the most recommended procedure.

I found several procedures on the internet, like: use Refactor, Change Gradle, do both or just one. Finally several examples.

I'd like to know which way is most recommended because the application is working properly.

    
asked by anonymous 14.09.2017 / 14:42

1 answer

4

Translation and adaptation this SOen response for this question on: Android Studio Rename Package .

For example, to change from br.com.dominio-x to br.com.dominio-y , then do:

  • In the Project Dashboard, on the left side of the screen, click the settings icon ()

  • Uncheck/De-selecttheCompactEmptyMiddlePackagesoption:

  • Now your package will be divided into individual directories.

  • Select each directory you want to rename individually:

    • Click the right mouse button
    • Select Refactor
    • Click Rename
    • In the dialog box, click Rename Package instead of Rename Directory
    • Enter the new name and click Refactor
    • Click Do Refactor in the window below
    • Wait a few minutes while Android Studio updates any changes.
    • * Note: When renaming with Android Studio, you can give a warning. In this case click on Rename All
  • Now open your Gradle Build File ( build.gradle - which is in app or mobile ). Update the applicationId to the new package name and click on Sync in Gradle if it is not updated automatically.
  • Ready! Anyway, Android Studio would need to make this process simpler.
  • 14.09.2017 / 15:09