How to change Android App Name and ID of an existing application?
Asked Answered
D

13

35

I have two Android projects in Eclipse. I copied the one project from the other, then changed the app name (in strings.xml) and the project name (in Eclipse).

But now there is a problem: When I run either of the applications in the emulator, the other one gets lost (maybe overwritten?). So I guess that there is another setting I have to make, so that Android recognizes the two apps to be different?

Thanks!

Darrendarrey answered 3/7, 2011 at 16:0 Comment(0)
P
13

Package name (in java).

The app name is also in the manifest, although I don't think that needs to be unique, but still would be good to change it for clarity.

Parturition answered 3/7, 2011 at 16:3 Comment(2)
True, changing the package name in Android Manifest helped me.Bornu
How will this affect already downloaded applications if you change everything and "re-release"Sohn
S
17

Actually you need to change the name in several places:

First, as you said, the name of the string, which is the visible name of the application.

Second, go to activity->src and right click on the package (com.example.whatever) and do refactor->rename;

Then go to the manifest.xml: and change the field in:

<manifest package="com.example.whatever" >

If you are using native code, JNI, you will also have to change the names of the c++ functions, which is a pain in the ass:

Java_com_example_whatever_activity_function()
Sullyprudhomme answered 29/11, 2013 at 11:6 Comment(1)
is there any solution to auto change JNI c++ function package nameBeaconsfield
M
17

For those who aren't using Android Studio and want to do it manually (e.g. if you're using React Native), I just recently went through this and had to change it in the following files:

index.android.js
android/settings.gradle
android/app/build.gradle
android/app/src/main/AndroidManifest.xml
android/app/src/main/java/com/<app id>/MainActivity.java
android/app/src/main/java/com/<app id>/MainApplication.java
Mobley answered 10/1, 2017 at 16:43 Comment(0)
P
13

Package name (in java).

The app name is also in the manifest, although I don't think that needs to be unique, but still would be good to change it for clarity.

Parturition answered 3/7, 2011 at 16:3 Comment(2)
True, changing the package name in Android Manifest helped me.Bornu
How will this affect already downloaded applications if you change everything and "re-release"Sohn
K
10

For Android Studio users, you need to change your package name in AndroidManifest.xml and also in build.gradle file --> defaultConfig--> applicationId.

Kinkajou answered 17/12, 2014 at 17:30 Comment(0)
F
10

My setup

  • Android Studio 3.5.3
  • Kotlin 1.3.x
  • macOS 10.14.6

Solution to Renaming appid

  • In Project Explorer, find app/java/com.company.app.
  • Right-click > Refactor > Rename, then select Rename Package.
  • Look down in the Refactoring Preview and make sure all package references are selected.
  • Click Do Refactor.

No need to hack around by hand.

Feld answered 27/12, 2019 at 2:57 Comment(1)
This worked, just had to clean build!Dank
H
9

The most simple way I have found to accomplish this task is to utilize Product Flavor in .gradle

productFlavors {
    MainApp {
        applicationId = "com.company.app"
    }
    NewAppFlavor {
        applicationId = "com.company.newapp"
    }
}

buildTypes {
    debug {
        buildConfigField "java.util.Date", "buildTime", "new java.util.Date(" +  getDateAsMillis() + "L)"
        applicationIdSuffix ".debug"
    }
}

You then specify package name in AndroidManifest.xml as

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.company"
   android:versionCode="1"
   android:versionName="0.1.1" >

Upon release configuration, Android Studio (1.5.1 as of this writing) will ask which flavor to build.

Debug configuration is a little less intuitive, you must hover the cursor over the bottom left corner of the screen, select "Build Variants" and select which flavor your debug configuration will deploy when you press the play button.

Higgins answered 14/2, 2016 at 6:43 Comment(0)
S
3

if you are using Android studio then
Your project identifier is in your build.gradle file just change the field applicationId "com.example.whatEver"
Hope it will work

Suppression answered 12/6, 2017 at 14:33 Comment(0)
M
3

I found that my rename wasn't working because I also needed to change the package name in google-services.json

Mezuzah answered 26/7, 2018 at 13:26 Comment(2)
Can you reuse the same google-services.json without creating a new app in Firebase?Gentille
I don't think so, google-services.json is specific to each application id.Nightgown
R
3
  1. Change applicationId on app gradle.

  2. Change file_provider_authority in strings.xml

  3. If you are using firebase then add new project on firebase and download the new google-services.json file and replace the old one with this.

Optionally change your app name as well.

Rain answered 27/11, 2018 at 7:59 Comment(1)
Can you reuse the same google-services.json without creating a new app in Firebase? Just changing client[0].package_nameGentille
A
1

An application's unique identifier is the package name. If you change the package name and reinstall the app again, you will end up with two copies on your phone.

Eclipse can change it on all the places of your code automatically.

Just right click your project on the package explorer (project tree) and go to Android Tools->Rename Application Package

Voilà.

Avesta answered 6/8, 2014 at 11:24 Comment(0)
O
1

Select Android on the top left of the Project window. So, right click over your package name under Java folder and select "Refactor" -> Rename... Click in Rename Package Button. Type the name of the new package you want, mark all options then confirm.

When it shows the results, click on "Do Refactor".

Onym answered 28/1, 2015 at 2:13 Comment(2)
Thanks, but it only allows renaming the last portion of the package name: instead of com.example.app it renames to com.example.new_app.Shoer
@Shoer You need to click the cogwheel and remove the selection on "Compact Middle Packages". Now you can change all levels.Gentille
M
1

After refactoring, a simple "Find and Replace" would help in fixing the renaming in files that were not affected by refactoring

Malacostracan answered 2/8, 2023 at 18:2 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Me
M
0

in build.gradle select applicationId and press command + shift + r and replace with new package name. then sync build.gradle. if you have error in manifest, add package name to start of class

Mikimikihisa answered 8/11, 2023 at 9:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.