varunrao321
varunrao321

Reputation: 965

Parse Error - Installing apk programmatically

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.

Upvotes: 1

Views: 3787

Answers (2)

Jitesh Dalsaniya
Jitesh Dalsaniya

Reputation: 1917

Installation can give the specified error at least in following cases:

  • Name of the package is changed after signing: Use the exact name as the signed package is (instead, adjust the name in Manifest)

  • Package is compiled against on higher API level: Correct the API level in Manifest file

  • Package is executed from SD-card: Run (install) the apk -file from phones memory OR use adb command to install it

Upvotes: 1

DKV
DKV

Reputation: 1767

Please check this code

  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);}

Upvotes: 0

Related Questions