React Native
Android Development
Package Name Change
Mobile App Development
Software Engineering

Change package name for Android in React Native

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Changing the Android package name in a React Native app means updating both Android configuration and the Java or Kotlin source package structure. If you change only the manifest or only the folder names, the Android build usually breaks because the application class and generated package references stop matching.

What the package name affects

The package name is the Android application identifier, such as com.example.myapp. It affects:

  • the app identity on a device and in Google Play
  • the Java or Kotlin namespace for Android source files
  • deep link and Firebase configuration in some setups
  • native module paths and generated build output

So this is more than a cosmetic rename.

Files you usually need to update

In a typical React Native project, the important Android files are:

  • 'android/app/build.gradle'
  • 'android/app/src/main/AndroidManifest.xml'
  • 'android/app/src/debug/AndroidManifest.xml'
  • 'android/app/src/main/java/.../MainActivity'
  • 'android/app/src/main/java/.../MainApplication'

The exact file extension depends on whether the Android code is Java or Kotlin.

Update the application ID

Start with the app module build file:

gradle
1android {
2    defaultConfig {
3        applicationId "com.newcompany.newapp"
4        minSdkVersion rootProject.ext.minSdkVersion
5        targetSdkVersion rootProject.ext.targetSdkVersion
6        versionCode 1
7        versionName "1.0"
8    }
9}

This controls the installed package identity. In newer Android projects, namespace may also be present and should match your intended source namespace where appropriate.

Update the package declarations in native source

If your old package was com.oldcompany.app, the source files likely start with:

java
package com.oldcompany.app;

Change them to the new package:

java
package com.newcompany.newapp;

Then move the files into matching directories. For Java, that typically means changing:

text
android/app/src/main/java/com/oldcompany/app/

to:

text
android/app/src/main/java/com/newcompany/newapp/

If you skip the directory move, Android Studio and Gradle will often complain that the declared package does not match the file path.

Check the manifests

In many React Native projects, the manifest package is inferred from Gradle settings or source declarations, but you should still inspect the manifests for old references. Update any authority strings, intent filters, or provider names that still use the previous package.

A typical snippet might look like this:

xml
1<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2    <application
3        android:name=".MainApplication"
4        android:label="@string/app_name">
5    </application>
6</manifest>

If you use explicit class names, they may need to change as well.

Clean and rebuild

After the rename, clear stale build output:

bash
1cd android
2./gradlew clean
3cd ..
4npx react-native run-android

A clean build matters because Gradle can keep generated files that still point at the old package.

Watch for third-party config files

Some integrations also embed the package name:

  • Firebase google-services.json
  • deep link configuration
  • push notification setup
  • app links and OAuth redirect URIs

If the Android app was already integrated with external services, those settings may need to be regenerated or updated after the rename.

Common Pitfalls

  • Changing only applicationId and forgetting to update Java or Kotlin package declarations.
  • Moving source files without updating the package line inside them.
  • Forgetting debug or test manifests that still reference the old package.
  • Ignoring third-party service files that are bound to the original application ID.
  • Skipping a clean rebuild and chasing stale Gradle output instead of the real issue.

Summary

  • Changing the Android package name in React Native requires both config changes and source namespace updates.
  • Update applicationId in Gradle and check any namespace setting.
  • Rename package declarations in native source files and move the folders to match.
  • Inspect manifests and third-party integrations for old identifiers.
  • Run a clean rebuild after the rename to flush stale generated artifacts.

Course illustration
Course illustration

All Rights Reserved.