Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
307 views
in Technique[技术] by (71.8m points)

android - Can't install APK hosted my own apache server

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...