9

I am aware that this question is asked several times in SO. I have checked below answers posted but doesn't work for me :(

Currently, my application's package name is "com.example.test".I want to change this to "com.example.test.test1".So, I just changed the package name in my manifest file and build the app.

Now ,if I run both the applications seperately with above package names changed from manifest files into device than it should show me different applications.It shows me error as "Failure [INSTALL_FAILED_CONFLICTING_PROVIDER]"

As the package names are different, it should show me different applications in the device instead of overriding one app with other.Help me out.

Any help would be appreciated.Thanks

Community
  • 1
  • 1
Siddharth_Vyas
  • 9,972
  • 10
  • 39
  • 69
  • 1
    Changing package name directly from manifest file does not reflect with the actual package name. You are suppose to change the package name explicitly of your packages also. Then only it will be reflected. Otherwise it will always gets conflicted with your actual application package name and manifest file package name. – GrIsHu Mar 11 '14 at 07:12
  • So basically, I will have to manually change the package name in each file? – Siddharth_Vyas Mar 11 '14 at 07:13
  • No you just need to rename your package name and your files will automatically asks for importing the latest package name. – GrIsHu Mar 11 '14 at 07:14
  • 1
    Check that you don't have package name specified in build.gradle also. Gradle is overwriting package name specified in manifest – Eugen Martynov Mar 11 '14 at 10:22

3 Answers3

28

The packageName attribute is deprecated as of Android Studio V0.0.6 onward. To change the package name of the application, use applicationId instead. Check the release notes here.

enter image description here

Change the applicationId and sync gradle.

C--
  • 16,393
  • 6
  • 53
  • 60
16

If your aim is to have the same application at two instance in the device, it is so easy to do using gradle. You don't need to change package name in the Manifest file, gradle will handle that during the build process for you and do all package renaming under the hood wherever required.

In order to achieve that you need to write a new product flavor for your app inside the main app module's build.gradle file with a different application id(package name). Eg. if com.example.test is your default package name of the app. You can have a different flavor of the same app with a different package name or knows as application id. produltFlavours can be defined inside android tag of your main module's build.gradle file like as shows below.

productFlavors {
    app1 {
        applicationId "com.example.test.test1"
    }
}

Sync your project after making the changes. Now select the build variant from Build Variant tab in left hand panel and hit run. Gradle script will handle all package renaming for you.

Check this once for more details :

Android Gradle Build Variant Deploy

Piyush Agarwal
  • 25,608
  • 8
  • 98
  • 111
2

What worked for me: 1. Right click package you want to change under java folder| 2. Refactor -> Rename| 3. Rename the package -> press "enter" -> press "Do Refactor"| 4. This updates all the files including the manifest