skip to Main Content

Refactor didn’t work in this case because, this is pre-made project with AppID: com.cit.app.cricket(4 words) but i want com.cit.app(3 words) in my appId. I was change tried change manually by searching the word but it was so difficult and not working properly, and in my Android Studio(Giraffe) there is no Select all option available, which helps me to select and remove a word from project.

I have tried refactoring but it didn’t work because i want to remove a word(cricket) from my appID(com.cit.app.cricket).

2

Answers


  1. Before you change your app id you’ll have to change your package name
    for that go to project root->app->src->main->java->
    change the com.cit.app.cricket to com.cit.app and do refactor to all
    and then change your app id in gradle

    Login or Signup to reply.
  2. There a few ways you can handle this. You change namespace and applicationId in your gradle build file. Just make sure to update all the relevant paths to your android components in the manifest to match the path specified in the namespace.

    As for the sources there is no auto refactor but there is a workaround. In your case select all source files under cricket (but not the cricket directory itself) and press F6 or go to Refactor -> Move package or directory. It won’t let you just move all the sources to the parent directory saying that directory already exists. But what you can is to specify target directory as something like com.cit.appbackup. Make sure to tick all the checkboxes so Android Studio does all the refactoring for you. After you OK you will end up with a source set that look like this:

    com
        └── cit
            ├── app
            │   └── [EMPTY]
            └── appbackup
                └── [YOUR SOURCE FILES]
    

    At this point just delete app directory and press Shift+F6 or go to Refactor -> Rename to rename your appbackup to app. Again, make sure to tick the checkboxes that handle imports. After you press OK everything should be just like you wanted.

    You will probably want to sync, clean and rebuild the project.

    Before you do any of this be sure to commit your changes and checkout on a new branch so you can easily go back in case something goes amiss

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search