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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
varunrao321
  • 925
  • 2
  • 10
  • 18
  • 1
    Looks like a problem with your APK. Check if you can download it from the server and install the downloaded file through adb. – Rajesh May 03 '12 at 08:19
  • Thanks a lot Rajesh, I will do it and keep you posted :) – varunrao321 May 03 '12 at 09:20
  • Whoops: didn't find expected signature, read_centraldirectory_entry_failed, file 'C:\APK\MyApp.apk' is not a valid zip file. this is what I got in cmd when I tried to install but when I installed the apk in the project/bin/ I was able to install the application. – varunrao321 May 03 '12 at 09:32
  • Something is messing up with your APK, possibly in the PDF <-> APK conversion process. – Rajesh May 03 '12 at 09:38
  • Thanks for your reply Rajesh. I loaded the apk file manually on the sdcard and tried, but no luck, it is showing the same error. :( – varunrao321 May 03 '12 at 10:10

2 Answers2

1

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

Jitesh Dalsaniya
  • 1,917
  • 3
  • 20
  • 36
0

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);}
DKV
  • 1,767
  • 3
  • 28
  • 49