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

和自甴很熟 提交于 2019-11-30 08:28:48

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.

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()

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

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

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.

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

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à.

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".

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

  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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!