Sometimes, we make our app using the code from youtube tutorials and blogs and may forget to change the package name at the start. Yes, this happens, most of the time.

We don’t want to display other website name or Youtube channel name to be as our package name, We want a package name that defines us. If you are searching for a tutorial about how to change or rename the Android app package name in Android Studio, then this post is for you.



In this post, I am going to discuss 3 methods that I am using and still working.

Method I – How to rename android app package name in Android Studio

In this example, we will change package name com.androidride.myapplication” to “com.xyz.yourapplication”.

STEP 1

rename android app package name

  • Open Android Studio project, Select package name or Java, Click the gear icon.

STEP 2

rename android app package name

  • Deselect Hide Empty Middle Packages. This breaks your folder structure into parts.

rename android app package name

  • The package is brocken down.

STEP 3

rename android app package name

  • Right Click on AndroidRide, Refactor -> Rename . You can also use Shift + F6.

A warning will appear.

STEP 4

rename android app package name

  • Click on Rename package

STEP 5

rename android app package name

  • Clear AndroidRide and put new Name in it. Here “xyz”

    STEP 6

    rename android app package name

    • Click Do Refactor

    STEP 7

    rename android app package name

    • Repeat the same process.
    • Right click on myapplication,Refactor -> Rename and Rename package.

    STEP 8

    rename android app package name

    • Change myapplication to yourapplication

    STEP 9

    rename android app package name

    • Click on Do Refactor.

    STEP 10

    • After changing the package name, open build.gradle(module) and change Application Id

    STEP 11

    rename android app package name

    • change applicationid “com.androidride.myapplication” to “com.xyz.yourapplication”.
    • After changing applicationid, click on sync now.

    Congrats. Package name successfully changed.

    Method 2 – How to change full package name of project by creating new package

    In this method, We are going to change package name “com.androidride.myapplication” to “info.xyz.yourapplication”

    STEP 1


    android studio how to change package name

    • Right click on com.androidride.myapplication package and select Refactor->Move

    STEP 2


    android studio how to change package name

    • Choose Move package “com.androidride.myapplication” to another package and click on OK.

    STEP 3


    android studio how to change package name
    Now you will get a warning dialog shows Multiple directories correspond to package com.androidride.myapplication

    • Click on Yes

    STEP 4


    android studio how to change package name

    • Enter the new package name except the last level, For example. If you want to make package name as “info.xyz.yourapplication” then type “info.xyz” only, like above. Avoid the last part, here “yourapplication”.

      STEP 5


      android studio how to change package name

      • Click YES for creating new package.

      STEP 6


      android studio how to change package name

      • Click on Do Refactor. Now package name “com.androidride.myapplication” changes into “info.xyz.myapplication“.

      STEP 7


      android studio how to change package name

      Now we have to change the last package level name,

      • Right click on package name -> Refactor -> Rename

      STEP 8


      android studio how to change package name

      • Click on Rename package

      STEP 9


      android studio how to change package name

      • Rename “myapplication” in to “yourapplication”.

        STEP 10


        android studio how to change package name

        • Click on “Do Refactor”

        STEP 11


        android studio how to change package name

        • Use CTRL key and select each package related to old package name and delete. You can use DELETE key in keyboard or right click after selecting old packages and click on delete option from the menu.

        STEP 12

        android studio how to change package name

        • Open build.gradle file, change applicationId and Click on sync now.

        Package name successfully changed to “info.xyz.yourapplication“.

        Method III – How to rename android app package name in Android Studio using existing package

        This method is also same as the second method. Just like second, we change package name “com.androidride.myapplication” to “info.xyz.yourapplication“.

        STEP 1


        android studio change package name of project

        • Right click on Java and select New -> Package

          STEP 2


          change apk package name android studio

          • Next dialog box appears, choose …app\src\main\java as Destination Directory.

          STEP 3


          how to change package name android studio

          • Enter your package name, here info.xyz.yourapplication

          STEP 4


          android studio how to change package name

          • Now move old package files into new package. Here move files from “com.androidride.myapplication” to “info.xyz.yourapplication“. Just use CTRL key to select all files and drag it to new package.

          how to change full package name in android studio

          • Files moved.

          STEP 5


          rename android app package name

          • Open AndroidManifest.xml and change package name into “info.xyz.yourapplication

          .

          STEP 6


          android studio change package name

          • Open build.gradle (Module: app) file, change applicationId also. Change it to “info.xyz.yourapplication” and Click on Sync now.

            Now you might get errors. It is due to the R file import. There are two scenarios, we can do.

            1. Remove R file import line from both files and check the error still exists. If not then you can delete old package files now
            2. It’s done. You have successfully changed the package name.

            3. Otherwise, If the error still exists, do the below steps.
            4. STEP 7


              change package name android studio

              • Select R file import line just like above and press CTRL + SHIFT + R . Replace with new package name. Click on replace all.

              STEP 8


              android studio change package name of project

              • Click on replace

              STEP 9


              change apk package name android studio

              • Delete old package and related files

              STEP 10


              how to change package name android studio

              • Build->Rebuild

              Yes, the package name is changed.

              Express your thoughts below and tell your friends about this post. Thank you.
              how to change package name in android studio