Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install APK hosted my own apache server

Tags:

android

I've exported an apk from eclipse. I am able to install it without any problem if I copy it to the phone's sd card.

When trying to download via phone's (Galaxy S) browser I get: "Download unsuccessful".

I have set mime type application/vnd.android.package-archive in the mime.types, restarted apache, still same result. Also tried :

<a href="downloads/my_apk.apk" type="application/vnd.android.package-archive">Download App</a>

Still no luck.

I am able to download and install applications from android market. I suspect that apache is not sending the mime type but this is just a shot in the dark. How can I fix the problem and be able to install APKs from my web server? (or at least to check if apache sends correct header with mime type)

Any help will be appreciated.

like image 240
Ognyan Avatar asked Aug 25 '10 19:08

Ognyan


People also ask

Why can't I run an APK file?

Depending on your device, you might need to give a specific app, such as Chrome, permission to install unofficial APK files. Or, if you see it, enable Install Unknown Apps or Unknown sources. If the file doesn't open, try browsing for it with a file manager like Astro File Manager or ES File Explorer File Manager.

How do you install APK on Android that Cannot be installed?

Tap on the Security option. Scroll down until you see Unknown sources and check the box. Open your file browser and navigate to your download folder where the APK is. Tap the APK and follow the instructions to install the app.


2 Answers

It is better if you add the .apk extension to the apache`s mime config. Take a look at this example: https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types

You can just find the "apk" record and copy the row to the file /etc/mime.types at your server:

application/vnd.android.package-archive     apk

Also add this to /etc/apache2/mods-available/mime.conf :

AddType application/vnd.android.package-archive .apk

(There are some other AddType-s, put it after them for sure). From here on you don't have to put anything for the apk`s mime-type in the tag, the server will handle this. ;)

UPDATE: fixed a bug in AddType line

like image 52
Vasil Popov Avatar answered Nov 11 '22 07:11

Vasil Popov


After all I found the problem thanks in part to CommonsWare advise.

Directory where I put apks for downloads is protected by simpe auth. Phone's browser correctly asks (once) for username/password when browsing it but obviously forgets to send auth info when trying to download the file and that causes 401 Unauthorized.

Solution: remove basic auth from that dir or use another unprotected dir for the apks.

like image 35
Ognyan Avatar answered Nov 11 '22 08:11

Ognyan