Change application package android

Change Application Package name through Android Studio

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

3 Answers 3

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.

Change the applicationId and sync gradle.

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.

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.

Источник

Is it possible to change the package name of an Android app on Google Play?

I would like to know whether it is technically possible, not whether it is easy or not, to change the actual package name of an Android app that is on Google Play. What I mean by package name is the name that will show up in the URL. Please, can anyone tell me why this is / is not possible? Thanks!

7 Answers 7

From Dianne Hackborn:

Things That Cannot Change:

The most obvious and visible of these is the “manifest package name,” the unique name you give to your application in its AndroidManifest.xml. The name uses a Java-language-style naming convention, with Internet domain ownership helping to avoid name collisions. For example, since Google owns the domain “google.com”, the manifest package names of all of our applications should start with “com.google.” It’s important for developers to follow this convention in order to avoid conflicts with other developers.

Once you publish your application under its manifest package name, this is the unique identity of the application forever more. Switching to a different name results in an entirely new application, one that can’t be installed as an update to the existing application.

Читайте также:  Как настроить utorrent для android

More on things you cannot change here

Regarding your question on the URL from Google Play, the package defined there is linked to the app’s fully qualified package you have in your AndroidManifest.xml file. More on Google Play’s link formats here.

Nope, you cannot just change it, you would have to upload a new package as a new app. Have a look at the Google’s app Talk , its name was changed to Hangouts , but the package name is still com.google.android.talk . Because it is not doable 🙂 Cheers.

As far as I can tell what you could do is «retire» your previous app and redirect all users to your new app. This procedure is not supported by Google (tsk. tsk. ), but it could be implemented in four steps:

Change the current application to show a message to the users about the upgrade and redirect them to the new app listing. Probably a full screen message would do with some friendly text. This message could be triggered remotely ideally, but a cut-off date can be used too. (But then that will be a hard deadline for you, so be careful. ;))

Release the modified old app as an upgrade, maybe with some feature upgrades/bug fixes too, to «sweeten the deal» to the users. Still there is no guarantee that all users will upgrade, but probably the majority will do.

Prepare your new app with the updated package name and upload it to the store, then trigger the message in the old app (or just wait until it expires, if that was your choice).

Unpublish the old app in Play Store to avoid any new installs. Unpublishing an app doesn’t mean the users who already installed it won’t have access to it anymore, but at least the potential new users won’t find it on the market.

Not ideal and can be annoying to the users, sometimes even impossible to implement due to the status/possibilities of the app. But since Google left us no choice this is the only way to migrate the users of the old apps to a «new» one (even if it is not really new). Not to mention that if you don’t have access to the sources and code signing details for the old app then all you could do is hoping that he users will notice the new app.

If anybody figured out a better way by all means: please do tell.

Источник

3 Methods To Change Or Rename Android App Package Name in Android Studio

Sometimes, we make our app using the code from youtube tutorials and blogs and may forget to change the package name at the start. Yes, this happens, most of the time.

We don’t want to display other website name or Youtube channel name to be as our package name, We want a package name that defines us. If you are searching for a tutorial about how to change or rename the Android app package name in Android Studio, then this post is for you.

Method I – How to rename android app package name in Android Studio

In this example, we will change package name com.androidride.myapplication” to “com.xyz.yourapplication”.

STEP 1

  • Open Android Studio project, Select package name or Java, Click the gear icon.

STEP 2

  • Deselect Hide Empty Middle Packages. This breaks your folder structure into parts.
  • The package is brocken down.

STEP 3

  • Right Click on AndroidRide, Refactor -> Rename . You can also use Shift + F6.

A warning will appear.

STEP 4

  • Click on Rename package

STEP 5

    Clear AndroidRide and put new Name in it. Here “xyz”

STEP 6

  • Click Do Refactor

STEP 7

  • Repeat the same process.
  • Right click on myapplication,Refactor -> Rename and Rename package.

STEP 8

  • Change myapplication to yourapplication

STEP 9

  • Click on Do Refactor.

STEP 10

  • After changing the package name, open build.gradle(module) and change Application Id
Читайте также:  Набор номера голосом для андроид

STEP 11

  • change applicationid “com.androidride.myapplication” to “com.xyz.yourapplication”.
  • After changing applicationid, click on sync now.

Method 2 – How to change full package name of project by creating new package

In this method, We are going to change package name “com.androidride.myapplication” to “info.xyz.yourapplication”

STEP 1

  • Right click on com.androidride.myapplication package and select Refactor->Move

STEP 2

  • Choose Move package “com.androidride.myapplication” to another package and click on OK.

STEP 3

Now you will get a warning dialog shows Multiple directories correspond to package com.androidride.myapplication

  • Click on Yes

STEP 4

    Enter the new package name except the last level, For example. If you want to make package name as “info.xyz.yourapplication” then type “info.xyz” only, like above. Avoid the last part, here “yourapplication”.

STEP 5

  • Click YES for creating new package.

STEP 6

  • Click on Do Refactor. Now package name “com.androidride.myapplication” changes into “info.xyz.myapplication“.

STEP 7

Now we have to change the last package level name,

  • Right click on package name -> Refactor -> Rename

STEP 8

  • Click on Rename package

STEP 9

    Rename “myapplication” in to “yourapplication”.

STEP 10

  • Click on “Do Refactor”

STEP 11

  • Use CTRL key and select each package related to old package name and delete. You can use DELETE key in keyboard or right click after selecting old packages and click on delete option from the menu.

STEP 12

  • Open build.gradle file, change applicationId and Click on sync now.

Package name successfully changed to “info.xyz.yourapplication“.

Method III – How to rename android app package name in Android Studio using existing package

This method is also same as the second method. Just like second, we change package name “com.androidride.myapplication” to “info.xyz.yourapplication“.

STEP 1

    Right click on Java and select New -> Package

STEP 2

  • Next dialog box appears, choose …app\src\main\java as Destination Directory.

STEP 3

  • Enter your package name, here info.xyz.yourapplication

STEP 4

  • Now move old package files into new package. Here move files from “com.androidride.myapplication” to “info.xyz.yourapplication“. Just use CTRL key to select all files and drag it to new package.

STEP 5

  • Open AndroidManifest.xml and change package name into “info.xyz.yourapplication

STEP 6

    Open build.gradle (Module: app) file, change applicationId also. Change it to “info.xyz.yourapplication” and Click on Sync now.Now you might get errors. It is due to the R file import. There are two scenarios, we can do.

      Remove R file import line from both files and check the error still exists. If not then you can delete old package files now

It’s done. You have successfully changed the package name.

Otherwise, If the error still exists, do the below steps.

STEP 7

  • Select R file import line just like above and press CTRL + SHIFT + R . Replace with new package name. Click on replace all.

STEP 8

  • Click on replace

STEP 9

  • Delete old package and related files

STEP 10

Yes, the package name is changed.

Express your thoughts below and tell your friends about this post. Thank you.

Источник

How to change package name of an Android Application

My keystore is corrupt, therefore the Android Market is requiring me to rename the app and resubmit it. However, whenever I go to edit the package names in Manifest and throughout the files, it gives me tons of errors.

What’s the proper way to change the application name?

18 Answers 18

There is a way to change the package name easily in Eclipse. Right click on your project, scroll down to Android Tools, and then click on Rename Application Package.

If you’re using Eclipse, you could try these instructions from Android’s developer site. They’re specifically for the GestureBuilder sample but should apply to any application as far as I can tell:

[H]ere’s how you could do this in Eclipse:

  1. Right-click on the package name ( src/com.android.gesture.builder ).
  2. Select Refactor > Rename and change the name, for example to com.android.gestureNEW.builder .
  3. Open the manifest file. Inside the tag, change the package name to com.android.gestureNEW.builder .
  4. Open each of the two Activity files and do Ctrl-Shift-O to add missing import packages, then save each file. Run the GestureBuilder application on the emulator.

Also, be sure you remembered to rename the package itself along with the references to it in the files. In Eclipse you can see the name of the package in the file explorer window/tree view on the left hand side. In my experience, Eclipse can sometimes be a little finnicky and unreliable with this (leaving behind stray references to the old package name, for example).

Here’s how you could do this in Eclipse:

  1. Right-click on the package name ( src/com.android.gesture.builder ).
  2. Select Refactor > Rename and change the name, for example to com.android.gestureNEW.builder .
  3. Open the manifest file. Inside the tag, change the package name to com.android.gestureNEW.builder .
  4. Open each of the two Activity files and do Ctrl + Shift + O to add missing import packages, then save each file.
  5. Run the GestureBuilder application on the emulator.

Update super easy way right click on your project.

In Android Studio, which, quite honestly, you should be using, change the package name by right-clicking on the package name in the project structure -> Refactor -> Rename.

It then gives the option of renaming the directory or the package. Select the package. The directory should follow suit. Type in your new package name, and click Refactor. It will change all the imports and remove redundant imports for you. You can even have it fix it for you in comments and strings, etc.

Lastly, change the package name accordingly in your AndroidManifest.xml towards the top. Otherwise you will get errors everywhere complaining about R.whatever.

Another very useful solution

First create a new package with the desired name by right clicking on the java folder -> new -> package.`

Then, select and drag all your classes to the new package. AndroidStudio will re-factor the package name everywhere.

After that: in your app’s build.gradle add/edit applicationId with the new one. i.e. ( com.a.bc in my case):

Original post and more comments here

Change package name and Activity names in AndroidManifext.xml and anywhere else it shows up in .xml files (custom view names, etc)

Update package import statement across all source files

Rename all folders to match the package name. Folder locations:
a. bin/classes
b. gen
c. src

Update the project name in build.xml (or your apk’s name won’t change)

Delete all the .class files in bin/classes/com/example/myapp/ (if you skip this step the files don’t get rewritten during build and dex give a bunch of trouble processing «class name does not match path» errors

Delete gen/com/example/myapp/BuildConfig.java (I don’t know why deleting BuildConfig.class in step 3a didn’t cause dex to update it’s path to this, but until I deleted BuildConfig.java it kept recreating gen/com/oldapp_example/oldapp and putting BuildConfig.class in there. I don’t know why R.java from the same location doesn’t have this problem. I suspect BuildConfig.java is auto-generated in pre-compile but R.java is not)

The above 6 steps are what I did to get my package name changed and get a successful* build. There may be a better way to handle steps 5 and 6 via dex commands to update paths, or perhaps by editing classes.dex.d in the root directory of the project. I’m not familiar with dex or if it’s ok to delete/edit classes.dex.d so I went with the method of deleting .class files that I know will be regenerated in the build. I then checked classes.dex.d to see what still needed to be updated.

*No errors or warnings left in my build EXCEPT dex and apkbuilder both state «Found Deleted Target File» with no specifics about what that file is. Not sure if this shows up in every build, if it was there before I messed with my package name, or if it’s a result of my deletions and I’m missing a step.

Источник

Читайте также:  Yandex mail apk android 4
Оцените статью