How to rename package name in Android Studio

How to rename Android Studio package

If you are working on an Android Project and working with IntelliJ's IDEA Android Studio and wondering how to rename the Java Package name, here is how you can do it,

Steps to Rename package Name: Android Studio

  1. Open your project, make sure you are in Project View
  2. Expand your app module and look for java, when you expand it you will see all your packages,
  3. Right click on the package example and go to Refactor -> Rename ..., you can also use shortcut Shift + F6
  4. You would see a warning window,
    Multiple directories correspond to package
    also generated:
    Do you want to rename the whole package or directory 
    C:\Users\c2c\AndroidStudioProjects\MyApp\app\src\main\java\com\example\myapp only?
    you can select Rename Package
  5. You would see a Rename window, change your package name and click refactor
  6. Under Refactoring, you can see what code will be changed, click do refactor after validating,
    Directory to be renamed to com.example.myapp1, Package to be renamed to myapp1
    References in code to directory com.example.myapp, package com.example.myapp (10 references in 9 files)
      (9 usages found)
        Unclassified usage  (5 usages found)
            app  (5 usages found)
                com.example.myapp  (5 usages found)
            (1 usage found)
                        1 package com.example.myapp;
            (1 usage found)
                        1 package com.example.myapp;
            (1 usage found)
                        1 package com.example.myapp;
            (1 usage found)
                        1 package com.example.myapp;
            (1 usage found)
                        1 package com.example.myapp;
        Usage in Android manifest  (1 usage found)
            app  (1 usage found)
                app\src\main  (1 usage found)
                    AndroidManifest.xml  (1 usage found)
                        3 package="com.example.myapp">
        Usage in Android resources XML  (3 usages found)
            app  (3 usages found)
                menu  (1 usage found)
                    menu_main.xml  (1 usage found)
                        4 tools:context="com.example.myapp.MainActivity">
                navigation  (2 usages found)
                    nav_graph.xml  (2 usages found)
                        10 android:name="com.example.myapp.FirstFragment"
                        20 android:name="com.example.myapp.SecondFragment"
    References in generated code to directory com.example.myapp, package com.example.myapp (10 references in 9 files)  (1 usage found)
        Unclassified usage  (1 usage found)
            app  (1 usage found)
                com.example.myapp  (1 usage found)
            (1 usage found)
                        4 package com.example.myapp;
  7. Note: You would require to make appropriate changes to build.gradle file manually.
  8. Build your project again and you should be done!

Another way of doing it is by creating a new package instead and copying all your contents there - but here you would require to manually update your AndroidManifest.xml and build.gradle file.

Try Out Code2care Dev Tools:


Android Java Linux Microsoft Google Python macOS Notepad++ Microsoft Teams CSS PHP SharePoint Html Linux C Programs Bootstrap jQuery Sublime Android Studio Facebook Eclipse WhatsApp News MySQL Json HowTos JavaScript FTP S3


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
🎉 We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
We strong support Gender Equality & Diversity.

We stand in solidarity with Ukraine - Make a donation to UNHCR -