Cannot download & install app APK from own webpage

20,618

Solution 1

Why can't I simply upload an APK and have a URL point to it for a download?

You can. Plenty of people do it. There are entire Web sites dedicated to doing it, albeit usually with pirated content.

Why am I getting a 404

Because the URL you are entering into the browser is not the URL where the file is at on the server. This is the cause of approximately 100% of 404 errors, across the Internet, regardless of circumstance.

what can I do to avoid it?

Use the proper URL. Also, be sure to set the server's MIME type configuration map to serve up your file as application/vnd.android.package-archive.

Solution 2

This is what i did in my asp.net application

My Application hosted under Window server 2008r2 having IIS 7

Step 1: In .aspx page add hyperlink set navigateurl as file path

 <asp:HyperLink ID="lnkdwnload" runat="server" NavigateUrl="~/Application_Android/MyAndroidAppAame.apk">Download MyApp</asp:HyperLink>

Step 2: Web.config add mimeMap element under staticContent

<system.webServer>
    <staticContent>
      <mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive"/>
    </staticContent>

</system.webServer>

Solution 3

in case you are using .net core,
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
...
var provider = new FileExtensionContentTypeProvider();
            // Add new mappings`enter code here`
            provider.Mappings[".apk"] = "application/octet-stream";
            app.UseStaticFiles(new StaticFileOptions()
            {
                ContentTypeProvider = provider
            });
}

Solution 4

Upload a web.config file in the directory where you keep the apk file

The content of the web.config should be :

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />
</staticContent>
</system.webServer>
</configuration>

Now you can download the apk file..

Solution 5

Thanks it is working

This is what i did in my asp.net application

My Application hosted under Window server 2008r2 having IIS 7

Step 1: In .aspx page add hyperlink set navigateurl as file path

<asp:HyperLink ID="lnkdwnload" runat="server" NavigateUrl="~/Application_Android/MyAndroidAppAame.apk">Download MyApp</asp:HyperLink>

Step 2: Web.config add mimeMap element under staticContent on same path

<system.webServer>
    <staticContent>
      <mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive"/>
    </staticContent>
Share:
20,618
Cody
Author by

Cody

Updated on July 05, 2022

Comments

  • Cody
    Cody almost 2 years

    I'm trying to have my apps available for download on a website, however, when I upload the APK file, it cannot be found by the browser.

    When zipping the APK, it is detected. However, not all phones can install from a ZIP - I have had mixed results.

    Why can't I simply upload an APK and have a URL point to it for a download? Why am I getting a 404 and what can I do to avoid it?

  • Cody
    Cody almost 12 years
    Using the exact same path, I don't get a 404 when the APK is zipped. How is that not the URL where the file is on the server? Just saw the last bit of your post, I haven't tried the MIME type config. I'll give that a shot.
  • CommonsWare
    CommonsWare almost 12 years
    Usually, a Web server will use some default MIME type for unrecognized files (e.g., application/octet-stream), but perhaps your host has an odd configuration. By way of example, if you download http://misc.commonsware.com/Now-debug.apk, it will install on your Android device. This is an APK file uploaded to Amazon S3, which automatically handles this particular MIME type.
  • amIT
    amIT over 9 years
    @CommonsWare I too am using amazon aws3 server to host my apk but i get "cant open file" error ,for AWS3 too does this MIME type has to be set manually ? how can i check/edit Mime type of a particular file uploaded in aws3 ?
  • CommonsWare
    CommonsWare over 9 years
    @amIT: ",for AWS3 too does this MIME type has to be set manually ?" -- probably, as the APK MIME type is a bit obscure. "how can i check/edit Mime type of a particular file uploaded in aws3 ?" -- I have no idea.
  • amIT
    amIT over 9 years
    @CommonsWare thanks ,can you please share the tool /procedure used by you to upload onAWS3 i use a plugin in firefox called "S3 organizer".
  • Satinder singh
    Satinder singh over 9 years
    Downvoted - reason the answer posted by you is word to word same of mine which i posted 2 years ago. Don't be a copypaster
  • equitharn
    equitharn over 8 years
    @CommonsWare even I'm facing the same problem, when i change the extension to .APK the file starts downloading but normal .apk results in 404 please help my question
  • d1jhoni1b
    d1jhoni1b about 6 years
    Thanks this what the reason, and i was actually using an IIS server