Steps to Change Package Name in Android Studio Project

0
356

Changing the package name in an Android Studio project involves several steps. Follow this guide carefully to ensure everything updates correctly.

Step 1: Open Project in Android Studio

  • Launch Android Studio and open your project.

Step 2: Change Package Name in AndroidManifest.xml

  1. Open AndroidManifest.xml (found in app/src/main/AndroidManifest.xml).

  2. Locate the package attribute at the top.

  3. Change it to your desired package name.

    Example:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.newpackage.name">
    

Step 3: Change Package Name in the Java/Kotlin Folder

  1. In the Project view, switch to Android mode.
  2. Expand app > java.
  3. Right-click your existing package name and select Refactor > Rename.
  4. Choose Rename Package.
  5. Enter the new package name and click Refactor.
  6. Android Studio will update occurrences of the package name in your code.
  7. Click Do Refactor to confirm.

Step 4: Update build.gradle (Module: app)

  1. Open app/build.gradle.

  2. Locate applicationId inside defaultConfig.

  3. Update it to the new package name.

    Example:

    defaultConfig {
        applicationId "com.newpackage.name"
    }
    
  4. Click Sync Now when prompted.


Step 5: Update google-services.json (if using Firebase)

  • If your project is connected to Firebase, download a new google-services.json file with the updated package name from the Firebase Console.
  • Replace the old google-services.json file in app/.

Step 6: Clean and Rebuild the Project

  1. Go to Build > Clean Project.
  2. Then go to Build > Rebuild Project.

Step 7: Invalidate Cache and Restart

  • Click File > Invalidate Caches / Restart.
  • Choose Invalidate and Restart.

Verifying the Changes

  • Run the app to ensure it works correctly.
  • If you encounter errors, check the log and update any missed occurrences of the old package name.
Search
Sellect from all Categories bellow ⇓
Read More
Entrepreneurship & Start-ups
How to Turn Your Passion into a Profitable Business
Turning your passion into a profitable business...
By flowisetech 2025-03-08 10:33:19 0 546
HTML
How to Create a Responsive Navbar With Additional Features Like Submenus, Animations, And a Dark Mode toggle
Creating a responsive navbar with additional...
By flowisetech 2025-02-21 12:00:15 0 402
Python
Steps on how to create telegram bot
Creating a Telegram bot involves several steps....
By Nicholas 2025-01-18 13:59:23 0 844
Smart Contracts
How Smart Contracts Work: The Backbone of Decentralized Apps
Smart contracts are self-executing contracts...
By flowisetech 2025-02-25 13:32:55 0 352
Self Development
Personal Growth & Mindset
Personal growth and mindset play a crucial role...
By flowisetech 2025-02-25 08:33:36 0 348