Serving Android Apk Files for Installation, Application/Vnd. Android. Package-Archive Parse Error

Serving Android Apk Files for Installation, Application/Vnd. Android. Package-Archive Parse Error

I am looking to enable download and installation of an android application package (APK) from my own server through a browser download. This appears to be blocked in the latest versions of android with the cryptic "There was a problem parsing the package" message. In the past (I forget which version of android) this worked just fine. Need help making it work in Android 11.

Here is the header content used to serve the file:

   header('Content-Description: File Transfer');
   header('Content-Type: application/vnd.android.package-archive');
   header("Content-Disposition: attachment; filename=\"".$filename.'"');
   header('Content-Transfer-Encoding: binary');
   header('Expires: 0');
   header('Cache-Control: must-revalidate');
   header('Pragma: public');
   header('Content-Length: ' . filesize($androidPackage));

Additionally, the MIME for APK files on the server is set to application/vnd.android.package-archive

The parse error occurs on the following phone configuration: Samsung Galaxy S10 on Verizon network Android version 11 (API 30) APK Build Target 28, Min 21

I have enabled special access:install unknown apps for the browsers.

The application still won't install from a browser (pointing to my server's website).

I have been able to upload the apk file to google drive and install from there (after permitting google drive to install unknown apps), so it does not appear to be a problem with the APK file, but a browser permissions problem.

I'm also able to install it to my local device using developer debugging.

4

1 Answer

CommonsWare suggestion worked.

If I direct the browser to the file directly, it will install, after first warning the user about installing unknown apps.

<a href="MyApp.apk">Direct Download</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Chloe Bennett
Author

Chloe Bennett

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.