[英]Inconsistent Parsing Error when trying to install an unsigned remote .apk file
[英]Error code -7 when trying to install release APK
我已经采取了所有适当的步骤来创建发布 APK。 ( 需要演示步骤)
我的设备(Nexus 7 2012)设置为允许从未知来源安装。
我通过电子邮件将 APK (app-release.apk) 发送给自己并尝试从 GMail 打开它,因为这应该可以。
编辑:我很抱歉,我还应该包括我确实从设置>应用程序>(有问题的应用程序)>“卸载”按钮卸载了该应用程序。
但是,应用程序立即无法加载,只有以下 logcat 信息:
05-30 14:44:41.689 466-497/? W/PackageManager﹕ Package edu.osu.expandablelistviewtest1 signatures do not match the previously installed version; ignoring!
05-30 14:44:41.914 466-497/? I/art﹕ Explicit concurrent mark sweep GC freed 74971(3MB) AllocSpace objects, 22(1348KB) LOS objects, 33% free, 28MB/43MB, paused 9.752ms total 220.463ms
05-30 14:44:41.927 20704-20704/? D/InstallAppProgress﹕ Installation error code: -7
05-30 14:44:43.094 20704-20704/? I/InstallAppProgress﹕ Finished installing edu.osu.expandablelistviewtest1
我已经尝试了所有我能想到的搜索字符串,但找不到任何关于错误 -7 含义的信息。 查看GitHub 上的代码,我们看到如下代码:
public void handleMessage(Message msg) {
...
if (msg.arg1 == PackageManager.INSTALL_SUCCEEDED) {
...
} else if (msg.arg1 == PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE){
...
} else {
// Generic error handling for all other error codes.
centerTextDrawable.setLevel(1);
centerExplanationLabel = getExplanationFromErrorCode(msg.arg1);
centerTextLabel = R.string.install_failed;
mLaunchButton.setVisibility(View.INVISIBLE);
}
...
private int getExplanationFromErrorCode(int errCode) {
Log.d(TAG, "Installation error code: " + errCode);
switch (errCode) {
case PackageManager.INSTALL_FAILED_INVALID_APK:
return R.string.install_failed_invalid_apk;
case PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES:
return R.string.install_failed_inconsistent_certificates;
case PackageManager.INSTALL_FAILED_OLDER_SDK:
return R.string.install_failed_older_sdk;
case PackageManager.INSTALL_FAILED_CPU_ABI_INCOMPATIBLE:
return R.string.install_failed_cpu_abi_incompatible;
default:
return -1;
}
}
...
}
...所以我们无法知道“-7”是什么意思。 (除此之外,它不是任何开关盒。)
我愿意接受任何想法/建议。 谢谢你。
嗯,我觉得很害羞。 毕竟,问题在于在较新版本的 Android 中,以我上面提到的方式卸载仅针对该特定用户进行卸载。
答案是转到设置>应用程序>(有问题的应用程序),然后从右上角的“...”菜单中选择“为所有用户卸载”。
所以对于未来的谷歌搜索者:
InstallAppProgress:安装错误代码:-7显然意味着您必须完全卸载应用程序的先前版本,例如先前的调试版本等。
PackageInstaller的错误代码常量在PackageManager类中定义,前缀为INSTALL_FAILED_ 。
(该链接对应于 2015 年 6 月 25 日的代码修订,因此当您阅读本文时,代码可能会更改。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.