尝试安装发布APK时出现错误代码-7

som*_*erd 11 java android

我已采取所有适当的步骤来创建发布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
Run Code Online (Sandbox Code Playgroud)

我已经尝试了我能想到的每一个搜索字符串,但无法找到有关错误-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;
    }
  }
  ...
}
Run Code Online (Sandbox Code Playgroud)

......所以我们无法知道"-7"的含义.(除此之外,它不是切换案例.)

我愿意接受任何想法/建议.谢谢.

som*_*erd 28

好吧,我感到羞怯.毕竟,问题是在较新版本的Android中,以我上面提到的方式卸载只卸载该特定用户.

答案是转到设置>应用>(有问题的应用),然后从右上角的"..."菜单中选择"为所有用户卸载".

因此对于未来的Google搜索者:

InstallAppProgress:安装错误代码:-7显然意味着您必须完全卸载以前版本的应用程序,例如以前的调试版本等.

  • 谢谢你,我找到了一个解决方案..另一种解决方案是运行'adb uninstall com.ephesoft.snapdoc'.. (3认同)