1

I am trying to install an apk file programmatically. I referred this site for doing it.

Now the apk file is downloaded from an url and placed in SDCard. When I try to install it on the device using Intent method,

It is popping up following error

Emulator:

 "Parse Error - There is a problem parsing the package",
Logcat(W) : "Unable to read AndroidManifest.xml of /mnt/sdcard/download/myapp.apk",
Logcat(W) : "java.ioException: AndroidManifest.xml",
Logcat(W) : "Parse error when parsing manifest. Discontinuing installation".
Logcat(E) : "java.lang.SecurityException",
Logcat(E) : "java.lang.NullPointerException".

Note: 1) I was able to install the same .apk file using adb. 2) I changed this .apk file to .pdf format before sending it to Server Team and then they changed it back to .apk. I am adding this coz there might be chances for error due to format conversion.

4

2 回答 2

1

安装至少在以下情况下会给出指定的错误:

  • 签名后更改包名称:使用签名包的确切名称(而不是调整清单中的名称)

  • 包在更高的 API 级别上编译:更正清单文件中的 API 级别

  • 包从 SD 卡执行:从手机内存运行(安装)apk -file 或使用 adb 命令安装它

于 2013-10-03T05:37:13.577 回答
0

请检查此代码

  private void installApk(){
                            Intent intent = new Intent(Intent.ACTION_VIEW);
                            Uri uri = Uri.fromFile(new File("/sdcard/path"));
                            intent.setDataAndType(uri, "application/vnd.android.package-archive");
                            startActivity(intent);}
于 2013-10-03T05:20:38.057 回答