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?
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.
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>
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
});
}
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..
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>
In Window Server go to IIS Manager, select your virtual directory and select MIME type
Add new MIME type -> Extension "apk" Type -> "application/vnd.android.package-archive .apk"
be sure add .apk extention
It will enable the apk file to download from Windows Server.
Related
I am testing Android Digital Asset Links for deeplinking, uploaded file to example.com/.well-known/assetlinks.json. But once I tested with Project1 successfully. Now I am trying to upload assetlinks.json of another Android project (Project2) to same host (example.com/.well-known/assetlinks.json). But server is not reflecting changes. Also I tried to remove file from server from .well-known folder it still exists in file list if I try to visit example.com/.well-known/
How that can be possible? Is Google webcrawled the file and showing me previous one? Or there are some standards for .well-known folder that once you upload a certificate you cannot change it?
Update
Another problem with this, first I tried with debug:
Then I am trying with Keystore it is giving this error(I already updated code at at server at /.well-known/assetlinks.json path):
Why it is giving error "We could not associate your app with selected domain"
I'm attempting to serve a json file for Android deep linking. I created a .well-known folder containing an assetlinks.json file in the root of my web forms project. When I publish the file up to an Azure App Service and navigate to the /.well-known/assetlinks.json path, I get a 404 error.
Is there something more I need to do to serve a static file?
Azure App Service does not support the static content of .json file by default. The solution is that add the content below to your web.config file under the path wwwroot. If there is not a web.config file, just create it.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
I have an app that will cache itself using appcache, which works fine on desktop and I can see the appcache status in the console and chrome://appcache-internals. However, on mobile it doesn't download the files at all and chrome://appcache-internals doesn't even show an entry.
manifest.appcache is as follows:
CACHE MANIFEST
# 2014-04-11:v4
index.php
favicon.ico
css/main.css
img/bg.png
img/logo.png
js/jquery-1.11.0.min.js
js/main.js
js/bigtext.js
NETWORK:
*
Nothing fancy at all, just completely baffling! Any help appreciated!
Apache wasn't being served with the correct mime type. Adding the following line to .htaccess resolves the issue:
AddType text/cache-manifest .appcache
I have developed an application,but when my client tries to download the application from the url provided using Samsung GT19003,it is downloading as .zip file and on click of that it says could not open the file error.Whereas it downloads as .apk and works good in our devices.Please help me as how can i resolve the issue.
Make sure that you have set the http Content-Type to application/vnd.android.package-archive
This let the chrome know that it is an application not a zip.
A simple solution is to add the below line in /etc/mime.types
application/vnd.android.package-archive apk
And restart your apache.
This will force browsers to download files as "apk" and not append "zip" to it.
if its being downloaded as .zip
You or your client can use File Expert application to unzip this .zip file it must show .apk file in the unzip folder
give a direct apk link to your user either he/she use default browser to download or use some other like opera and if it is .apk file link then it must be downloaded as is.
you may be using some content site which zip file on particular download methods please ensure it for direct .apk link.
EDIT 1:
Last but not the least .apk is just a zip file so this is not an issue just rename it(From .Zip to .apk) if you could and i hope it will solve the problem
In my case also the issue was same as #alireza-fattahi mentioned regarding the header.
Sharing this here because in our case the file was in Azure Storage and accessed by a CDN in case anyone has the same issue.
Fix for Azure Sorage and CDN
By default the APK blob that was uploaded had content type of application/zip and the same content type reflected in the reposnse header causing the downloaded file to get a .zip extension on Android OS when download was finished.
I had to set a custom rule in the storage CDN to overwrite content-type header in the response to application/vnd.android.package-archive
Remember to purge the CDN cache after you set the new rule
Read more about Azure CDN rules engine.
Here is the Example :
// set your download apk path here
$path= public_path(). "/upload/apk/Ninja11.apk";
//Set header here like this
$headers = [
'Content-Type'=>'application/vnd.android.package-archive',
'Content-Disposition'=> 'attachment; filename="ninja-release.apk"',
];
return response()->file($path , $headers);
This is Laravel framework code but in the same way, you can use in other frameworks. Simply you need to set the Content type
Note : This is not Android side issues
I'm write a Android web App Use jQuery mobile/HTML5/Use Phonegap/Eclipse/jqmphp, jqmPhp is a package of PHP classes, it echo the HTML dom elsements, I see its source,
define('JQMPHP_JQM', 'http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js', true);
But I want host the JavaScript and CSS in the APK file to reduce the HTTP request. How Can the HTTP web call the APK's resource?
assets/www/foo.js -> <script src="./foo.js"></script>
You can host the files in the android assets folder, just include the files in regular script tags in your index file.
Also, there are newer, more stable versions of jQueryMobile available.