简体   繁体   中英

Unable to download .apk via webbrowser from drupal site

I have a drupal-based website where people can log in and see private discussion forums. This is where I want to have my beta testers for my Android application download the beta .apk files. I tested this thoroughly on my Android 1.6 based myTouch 3G, and was able to log in, and download files attached to forum posts without problems.

Now comes the interesting part: my testers on Droids and Nexus Ones (Android 2.0.1 and 2.1) were complaining that their downloads are failing. Since I don't have an 2.0 phone, I tried it out in a 2.0 emulator, and lo-and-behold, it didn't work. The download shows the indeterminate progress for a second or two, then shows "Download unsuccessful".

Based on what I see in the logs, it is apparent that the server is returning a 404 for the download request from 2.0 browsers. I can download to my desktop and 1.6 phone no problem. The only reason I can think of that the server would return a 404 for a request is that for some reason the credentials or cookies aren't being passed by the download process. Logcat shows: http error 404 for download x

Some background: I added the mime type to my .htaccess like this: AddType application/vnd.android.package-archive apk

I checked the server logs and see the following for failed downloads: xx.xx.xx.224 - - [28/Jan/2010:20:39:00 -0500] "GET /system/files/grandmajong-beta090.apk HTTP/1.1" 404 - " http://trickybits.com/forums/beta-testing/grandma-jong/latest-version-090-b1 " "Mozilla/5.0 (Linux; U; Android 1.6; en-us; sdk Build/Donut) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1"

This sounds like it's related to a long standing problem I've experienced when trying to serve APK's from my own web server. This is not the MIME problem, its not file permissions and there's no path tomfoolery going on. It's as far as I can tell a bug in the Android browser. What I find is with Apache, if I add a .htaccess file which restricts the file/directory, ie you'd want it to prompt for a username/password when downloading from a browser, it fails with the error you describe. Remove the .htaccess and all is well. Not good when you've a public website you want to stick your secured test APK's on. Your site is drupal - I'd check for any restriction like this in effect, or indeed if it's not the restriction itself but the presence of the .htaccess file since the exact cause isn't clear.

By the way, an elegant solution to this is to use dropbox. You get your users to install it on their handsets, and when you drop the APK to it, not only are they all notified immediately, but they can then just click the link in their status bar and the app installs, ie no MIME or server work needed at all.

I know this is an old issue, but I'm having the same problem nowadays.

The only workaround I found is to ask users to download the apk from a non built in navigator which is very confusing and annoying (Opera is in fact working ok).

If anyone has found a solution for the build in browser, it would be really appreciated if posted! :)


Also I've noticed:
I'm working in a LAN where the server is in 192.168.1.15. I have resolved in "hosts" of local computers the domain name to the server address (if not, the domain name resolves to the router). In Android I haven't resolved the domain name, so when the internal browser tries to navigate to the domain name, instead of resolving to the server, it resolves to the router, as expected. What is surprising is that Opera is resolving to the server, like if there was a proxy or something like this. At least it acts like if the traffic is comming from outside the LAN.

Maybe this is what is making Opera to work on downloading the files.

Sorry if my english is not well enough to explain more clearly but hope it is understandable.

The default storage location for drupal files is /sites/default/files. If you uploaded the file via Drupal (as a node or whatever) it will be here. You should also check out the file /sites/settings.php or your file uploads settings (http:///admin/settings/file-system) to see where your files are being stored.

This is not a MIME type issue, so remove the entry for the apk files unless you want the server to attempt to read them.

Are the apk's signed? Maybe the later versions of Android expect only signed apps. http://tordtech.blogspot.com/2009/10/signing-android-applications.html

As the owner of a 2.0+ phone (Droid X) I found that I was having the same issue trying to download my own APKs. I worked around it: oddly enough, downloading Astro File Manager, for whatever reason, enabled me to do so.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM