Can not install apks from File Manager or browser? In the answer to this question I specifically discovered that I could not install the VLC nightlies. It had nothing to do with that answer, which was on a question about which version of VLC was right for that device. But that question was in fact inspired by this problem: I never previously had an APK I couldn't install by merely downloading, when I am in the Android Web Browser, and it downloads the APK, I can click on it in the notification applet at the top. When I do, it says


  Can not open file


When I open that file up with the LineageOS Files Manager, com.android.documentsui I get the same error. Now, I'm wanting to know what specifically is borked about just the VLC packages? Does anyone else get this problem? Why is that pm install ./appname.apk in the shell works, but the GUI doesn't?

I'm using LineageOS 14.1-20180616, based on Android 7.1.2.
Installing

With the  LineageOS File Manager

It seems that inside the File Manager, there are two discrete things Download a directory, and Downloads some broken nonsense shortcut link:


Does not work: On the left nav, you'll see Images Videos Audio Recent, and then Downloads Documents, and SM-P600. Installing from the Downloads on the right bar, gives this error.
Works: Going into the device at the bottom of the left nav (which is actually just a link to /data/media/0 and then clicking on Download will take you Download which is actually different from Downloads (plural and on the Left Nav). From this you can install the APK.


With the CLI


Enable ADB in the Settings
Run adb shell on the host
Browse to /sdcard/Downloads or /data/media/0/Download with cd. If you're unsure where the apk is located try running

find / -name 'VLC*-ARMv7.apk

Locate the apk and install with pm

pm install ./VLC*-ARMv7.apk



The problem

The problem seems to be that VLC web server answers the request with a response that has content-type: application/octet-stream like this,

$ curl -s -I "https://nightlies.videolan.org/build/android-armv7/VLC-Android-3.0.11-20180618-0249-ARMv7.apk" 
HTTP/2 200 
server: nginx/1.15.0
date: Tue, 19 Jun 2018 03:16:06 GMT
content-type: application/octet-stream
content-length: 25048251
last-modified: Mon, 18 Jun 2018 06:05:02 GMT
etag: "5b274b8e-17e34bb"
accept-ranges: bytes
x-clacks-overhead: GNU Terry Pratchett
strict-transport-security: max-age=31536000


Rather than application/vnd.android.package-archive. This means that you can't install through the browser, or the Downloads shortcut. This is because APK files are just zip files:

$ file VLC-Android-3.0.11-20180618-0249-ARMv7.apk 
VLC-Android-3.0.11-20180618-0249-ARMv7.apk: Zip archive data, at least v2.0 to extract


So what the File Manager and browser are trying to do is open them as such -- and you don't have something that hands Zip archive data 2.0+