Change android domain design

Asked

Viewed 4,359 times

2

I need to change the domain of my android project.

Example:

When I created the project I placed a fictional domain: br.com.dominio-x

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

I need to make this change and I don’t know what the most recommended procedure is.

Obs: I found several procedures on the internet, such as: use Refactor, Change Gradle, do both or only one. Anyway several examples.

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

  • Change in Graddle and Androidmanifest, it is not necessary to change in the manifest, but if you want to leave everything neat hehe changes in the manifest tmb..

  • See: https://stackoverflow.com/a/29092698/2570426

  • @Matheus "it is not necessary to change the manifest," that is not true, see https://developer.android.com/studio/build/application-id.html#change_the_package_name. There it is said the following: "However, if you want to change your package name, be Aware that the package name (as defined by your project directory Structure) should Always match the package attribute in the Androidmanifest.xml file"

  • @ramaral in the company where I work, I had to unify all the application code to generate other applications, and to do this I just change the grandle id.

  • @Matheus I believe, just mentioned what is said in the documentation. I withdraw the part " that is not true".

  • @ramaral haha that this, maybe I am wrong too kk if it is we will find out in a while when the bombs explode =)

  • @Matheus See the last paragraph with the title "One more Thing to know:". Maybe that’s why you’re right. Anyway the documentation is ambiguous (something I already know but sometimes forget).

  • @quiet ramaral I’ll take a look yes, I appreciate.

  • Another aspect that should be taken into account is what is said in the first paragraph regarding the amendment of applicationId in the build.Gradle: "... Once you Publish your app, you should Never change the application ID."

Show 4 more comments

1 answer

8


Translation and adaptation of Soen’s reply for this question about: Android Studio Rename Package.


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

  1. In the Project Panel, left corner of the screen, click the settings icon ( Gears icon )

  2. Deselect/De-select the option Compact Empty Middle Packages:

Compact Empty Middle Packages

  1. Now your package will be divided into individual directories.

  2. Individually select each directory you want to rename:

    • Click the right mouse button
    • Select Refactor
    • Click on Rename
    • In the dialog box, click Rename Package instead of Rename Directory
    • Enter the new name and click Refactor
    • Click on Of the Refactor in the window below
    • Wait a few minutes while Android Studio updates all changes.
    • *Note: When renaming with Android Studio, you can give a warning. In this case click on Rename All

enter image description here

  1. Now open your Gradle Build File (build.gradle - Which is found in app or mobile). Update the applicationId for the new package name and click on Sync in Gradle, if not updated automatically.

Refactor Directories

  1. Ready! Anyway, Android Studio would need to make this process simpler.
  • 1

    I find it useful to have the answer in Portuguese. + 1 for the translation work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.