Changing the package name of an upgraded Android application

孤人 提交于 2019-12-04 20:16:24

问题


During the upgrade of my android application, I changed the package name. But Android market doesn't allow to upload the changed package name application as an upgrade. If I upload the application as a new application, will the user have two applications on his/her device? How can I make sure that the user doesn't have to download the application again from scratch without reverting the change of my package name?


回答1:


two package = two different application in market place. Once you upload one app, its package should be same. Also, the key should be same.




回答2:


Android market is only concerned about the package name in your manifest, not the actual packages name in the source.

You could try to give the old package name in the manifest attribute, then for activities give the new package name instead of relative (ie .MainActivity)

Like this:

<manifest package="your.old.package" ...>
   ...
   <application android:name="your.new.package.MainActivity" ...>

Could work..

I plan to serve two versions of my app (paid/free) this way and using same project and code.




回答3:


If you change the package name, it's treated as a separate app - not just in the market, but apk's in general will only 'replace' the same package name (and only if they're both signed with the same key).

Although it's possible to phase over to a new key by signing an intermediate package with both keys, there's currently no easy way to phase over the package name.

The best that can be done is this:

  • New apk version is signed with the same key, but has a different package name.
  • When installed, the new apk arranges to use the shared_prefs with the old package name.
  • The data is copied across to the new package name.
  • The new version requests that the old version is removed, and the user sees the uninstall dialog.

Note app data is usually kept here:

/data/data/pac.kage.name/

I haven't tried this, so I can't give anymore details yet. You may also be interested in my request for a seamless way of transitioning the package name.



来源:https://stackoverflow.com/questions/4612211/changing-the-package-name-of-an-upgraded-android-application

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