Changing the package name of an upgraded Android application
During the upgra开发者_高级运维de 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?
two package = two different application in market place. Once you upload one app, its package should be same. Also, the key should be same.
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.
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.
精彩评论