如果你在android上更新一个已经安装过较早版本软件时,安装到最后一步提示你:已安装了存在签名冲突的同名数据包,然后安装失败。这是因为旧版软件的签名信息与新版不一致造成的。你可以卸载这个软件,然后安装新版软件。
如果无法卸载,可能手机(pad)在发售前将该软件内置在手机中无法卸载。如果是这个原因的话,你可以尝试“root”系统,然后卸载掉该软件的旧版本,然后安装。
如果你是一个开发人员,那么出现这个问题可能是因为,较旧的版本你是使用eclipse自动发布到模拟器上的,而eclipse自动发布时使用的是一个测试用签名,这个签名与你正式打包的签名不是一个。(这个问题一般发生在测试自动更新功能上,嘿嘿)。想继续测试自动更新,解决的办法也很简单,手工删除该软件的旧版(eclipse自动安装的那个),然后使用adb工具安装旧版再测试新版就好。自动更新的安装代码一般是这样:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("file://" + apkfile.toString()),
"application/vnd.android.package-archive");
mContext.startActivity(i);
或许你和这略有不同,不用担心,没什么,问题不在这里。
下面是给外国朋友的,请原谅我蹩脚的英语:
for foreigner,please forgive my broken:
When you try install a new version of a software on android, maybe you will receive this message: an existing package by the same name with a conficting signature is already installed!
I take it easy! Uninstall old version soft, and then install new version. In this process , maybe you need get "root" popedom.
If you are developer, you receive this message maybe because the old version is install by the eclipse. Eclipse use a debug keystore signature. I guess you try test you autoupdate function. You can uninstall it (eclipse auto package version) in setting tool. And install the old version (which you signature package) by ADB.exe before you test autoupdate function.
Autoupdate function code always like this:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("file://" + apkfile.toString()),
"application/vnd.android.package-archive");
mContext.startActivity(i);
If you code not like this , dont worry , never mind, the question not in there.
:)
原文地址:http://hi.baidu.com/cenxcen/item/824ff249eb5909f2dd0f6c64
在android软件开发中,总是需要更新版本,所以当有新版本开发的时候,就需要软件有自动更新的功能,让用户无需自己去手动更新方便用户
具体的过程网上有很多我就不多说,现提供一些链接供大家参考
http://www.cnblogs.com/wainiwann/archive/2012/03/12/2391810.html
http://blog.youkuaiyun.com/android_tutor/article/details/7015986
http://blog.youkuaiyun.com/xjanker2/article/details/6303937
以上文章都实现了android程序自动更新功能,网友可以参考。
现在讲一下我遇到的问题,我也是按照以上方法去实现的,发现以下的问题:
1。当下载完以后,安装的时候,系统显示正在安装,然后就没有,回到了主页,没有显示安装成功的界面,让用户不知所措。
2.。出现“install_failed_already_exists”这个错误。
3。出现“INSTALL_FAILED_VERSION_DOWNGRADE”这个错误。
纠结了一天多终于找到答案了。
对于第一个问题,原来在按装程序的时候我用的代码是如下:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://xxxx.apk"), "application/vnd.android.package-archive");
context.startActivity(intent);
这在android4.0以前的系统中没有什么问题,但是在android4.0及其以后的系统中就不显示安装成功的界面,应该添加一句:
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
才会出现安装成功的界面。
对于第二个问题,先前已经安装过这个程序,悄可能需要先卸载再重新安装。
第三个问题是你当前程序的版本低于已经安装过和版本号,所以卸载再安装。
还有如果一个问题就是,如果你两个版本的签名文件不一样的话,也会出现第二问题,而且用户在自动更新的时候会报第二个错误,所以在做自动更新的时,要使用同份签名证书,这个切记。
原文地址:http://blog.youkuaiyun.com/lovexieyuan520/article/details/9250099