The application ID (application package) defines the unique identity for an app. It must be universally unique in order to publish an app on Google Play Store. Every Android app has a unique application ID that looks like a Java package name, such as com.example.myapp. A user cannot deploy apps with the same application ID on the same device simultaneously. And, if you change it, the APK is considered to be a different app and users of the previous version will not receive an update. The application ID is specified in the package attribute of the manifest element as application package.
When you create a new project in Android Studio, the applicationId exactly matches the Java-style package name you chose during setup. However, the application ID and package name are independent of each other beyond this point. You can change your code’s package name (your code namespace) and it will not affect the application ID, and vice versa. You can either change the application ID through rename refactoring, or on build time. And although the application ID looks like a traditional Java package name, the naming rules for the application ID are a bit more restrictive:
- It must have at least two segments (one or more dots).
- Each segment must start with a letter.
- All characters must be alphanumeric or an underscore [a-z, 0-9, _].
1. Through rename refactoring
Follow these steps to rename Android application ID through rename factoring.
- With Android Studio, open the AndroidManifest.xml file.
- Position the cursor at the package attribute of the manifest element.
- Choose Refactor > Rename from the context menu.
- In the Rename dialog box that opens, specify the new package name and click “OK”.
2. On build time
Follow these steps to rename Android application ID on build time.
- With Android Studio, go to File > Project Structure from the main menu.
- Select “Modules” in the left pane.
- In the central pane, expand the node of the relevant module and click “Android”.
- In the right pane, switch to the “Packaging” tab and select the “Rename manifest package” option.