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>
Related
Is it possible to get the config.xml file that is generated by Cordova based applications using Adroguard?
I cannot find it under the /res folder and it is not listed in the output of get_files() method.
apktool, on the other hand, is able to get the config.xml from the apk that is use it on.
Since it is under res folder, You need to get it by unzipping the file to a temporary directory and then parse it using Axml parser. In get_files(), you must see "resources.arsc" file. The res files are part of that. You can do something like :
config_xml_path = os.path.join(<your apk unzipped path>, 'res', 'xml', 'config.xml')
with io.open(config_xml_path, 'rb') as axml_file:
parsed_axml_file = AXMLPrinter(axml_file.read())
axml_content = parsed_axml_file.get_buff().decode('utf-8)
parsed_axml = minidom.parseString(axml_content.encode('utf-8'))
You might get some errors if the config.xml is badly formatted but I am not including the solution to handle those case. I hope you will get an idea with the above example.
We're developing an android application with cordova were files will be synchronized.
Cordova is up to date, but the problem is that our files are saved in the main storage directory.
The file url looks like:
file:///storage/emulated/0/{our_directory}//
After a cordova update we were forced to set
<preference name="AndroidPersistentFileLocation" value="Compatibility" /> in the config.xml, for still finding our files.
Now we really would like to have our files in the internal data directory.
So if course we just could remove the "Compatibility" setting in the config.xml but then all files would be invisible.
If we change to internal data directory we are having two problems:
In a transition period we need to have access on both directories (Compatibility: file:///storage/emulated/0/{our_directory}// and the new correct internal data directory: file:///data/user/0/{our_app_id}/files/files/{our_directory}//).
If we change to interal window.requestFileSystem(LocalFileSystem.PERSISTENT,0,fn) delivers the root directory of the internal app data directory. So how can I read or write to files which are not in this directory? I found out, that cordova.file.externalRootDirectorydelivers the old path. Any ideas on how to access to both directories?
The other thing is, that we may would like to move all the files from the old directory into the new correct internal app data directory. Any ideas on how to do this?
Thanks ahead!
If you already know the URL you want to store and retrieve files from you can use:
window.resolveLocalFileSystemURL(URL, callback);
The callback will be passed the directory entry.
To move files you can use the fileEntry method moveTo.
entry.moveTo(parentEntry, "newFile.txt", success, fail);
I know this documentation is for Cordova 3.3.0 but I believe it is still relevant.
https://cordova.apache.org/docs/en/3.3.0/cordova/file/fileentry/fileentry.html
I need to load an mp3 on iOS from the www folder next to my HTML. I'm using phonegap and my code is basically the same as the example from : http://docs.phonegap.com/en/2.0.0/cordova_media_media.md.html
Its working on iOS and android when I use an mp3 from the web but if I try to load one from the www then I am getting a window saying I can't use the ressource (on ios).
I added this in my config.xml :
<feature name="http://api.phonegap.com/1.0/device" />
<feature name="http://api.phonegap.com/1.0/file" />
<feature name="http://api.phonegap.com/1.0/media" />
<gap:plugin name="org.apache.cordova.media" />
I am testing with the phonegap app for ios (http://app.phonegap.com/) from my phonegap server on windows and debuging with wienre. The rest of the app is working just the sound doesn't start.
I tried several different path :
"mySound.mp3"
"file://mySound.mp3"
"file:///mySound.mp3"
I also tried changing to an older phonegap version with no more luck.
Looking at the doc (same page as before) i should be able to just use the name of my file :
order of file search: When only a file name or simple path is
provided, iOS searches in the www directory for the file, then in the
application's documents/tmp directory:
var myMedia = new Media("audio/beer.mp3") myMedia.play() // first
looks for file in www/audio/beer.mp3 then in
/documents/tmp/audio/beer.mp3
I spent hours looking on internet and testing and i can't get that sound to start :/
Help would be much appreciated!
From what I know, iOS works with .wav file type. Maybe you should change your file type from .mp3 to .wav. Add the following to your config.xml
<plugin name="Media" value="CDVSound" />
iOS plays mp3 files. He only records in wav.
I should start by giving some background. We're about to release a non profit html5 children's game for android platforms. I have used eclipse to create an apk file but there is no audio (the rest of the game works fine). I have tried phone gap but there is no audio for the game. After doing days of research and possible solutions, I decided to ask here on stackoverflow.
The game uses html/css/js.
Project folder structure in Eclipse is:
assets(android_assets)->www->index.html, game.xml, js Folder (the game engine), styles Folder, and assets Folder.
The sub asset folder contains -> music folder, images folder, and backgrounds folder
Error Message:
The index.html file loads the game.xml. The game.xml file loads all the files in the assets folder. However, all music files are not found in logcat:
Failed to open file '/android_asset/www/assets/music/song.mp3.' (No such file or directory). My xml file sound call is: <source href="assets/music/song.mp3" type="mp3" />.
I use this same reference structure with images and backgrounds that are currently loading fine. When loading the music from an external url like www.oursever.com/song.mp3. The game is able to play the song just fine when running as an apk file on an Android device. So the code is right but the local file path to the song in the apk file is wrong.
After much reading, I learned that the assets folder is compressed and it is not recommended to read audio files from that folder without uncompressing them. The alternative is to place the mp3 files in the res/raw folder. I change my xml to read: ''. However, I receive the same error about the file not being found. I know items place in the res folder uses identifiers. But I'm not sure what I should put in the xml source file path to reference the song in res/raw. I printed out the file path to the song by using this code: System.out.println("Raw Path: " + getString(R.raw.menu));
Oh another method I tried, was pushing the entire app to the SDCard. I still received the "cannot find file" error.
Application Permissions:
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
Summary
The game works fine on our local webserver with all assets. When trying to create an apk file using Eclipse and Phonegap options produces the game with no audio. I read that the assets folder has a 1 mb limit per file so that is another reason why I am attempting to use res/raw folder. The only issue that is stopping us from publishing this non profit children's game is that I cannot find where the music file is located at within the apk file. I have explored the apk file contents and it shows that song.mp3 is inside res/raw/ folder. However the Android SDK states it not. Does anyone have any ideas?
Thank you four time,
Its my first time posting here so let me know if anything is confusing.
UPDATE 1
I tried an alternate idea by trying to read the song from the SD Card, when I tried this I received a permission denied error (so it did find the file). Even though I have READ_EXTERNAL_STORAGE permissions set, my app is being denied from using the mp3 file. So I tried copying the song from the raw directory, making a new folder on the sd card, and placing the file in the new folder by using this link:
How to Copy Raw files into SD Card
When using this solution the folder is never created and the file is never copied either. I also cannot find my app after installing it to my phone. I checked the internal storage->sdcard folder and examine the com folders. I also checked my external storage->sdcard for the com.mycompany folder and its not their either. Our test phone is running Android 4.1.2.
Update 2
I tried the suggestion for the sample project ''. I receive the error Failed to open file 'android.resource://com.mycompany/raw/song.mp3'. (No such file or directory). Song.mp3 is located in the res/raw folder. I tried an alternate idea by trying to read the song from the SD Card, when I tried this I received a permission denied error (so it did find the file). Even though I have READ_EXTERNAL_STORAGE permissions set.
Update 3
I'm working on a blank project again from scratch. The tutorial I used for the previous project is: https://www.youtube.com/watch?v=QRa4yMjoI7c
I'll update this post next Monday, thank you Andrew and anyone else that at least viewed this post.
Update 4
I have made a sample project that I have uploaded here:
http://tinyurl.com/p7s5w2v
Go to file then download.
The project is extremely small but you can see that I put the menu.mp3 file in the raw/res directory and that 'android.resource://com.mycompany/raw/menu.mp3' is unable to find the song when called in 'fisher.xml'. The song plays correctly on our webserver and our local server. But menu.mp3 cannot be found when running on an android device or emulator. I can always tell the xml file to load all the audio files for the game from our webserver but this will be slow.
Update 5
Current Tries:
source href="android.resource://com.brg.example/raw/menu" file not found
source href="sdcard/menu.mp3" permission denied on sdcard (app has read access)
source href="storage/sdcard0/menu.mp3" permission denied
source href="file:///assets/music/menu.mp3" file not found
Manifest File:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.brg.example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.brg.example.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Update 6
I have decided to settle on loading the media files from a remote server using a url. I initially thought converting a html project to an android webview with audio would be less time consuming than other platforms. I was mistaken with this. We may revisit Android again in the future. PhoneGap support team has been basically silent after we paid for their service. I thanked everyone that decided to glance at this posting.
Try this: "android.resource://com.your.package/raw/filename"
I've just had a similar problem -- for me the key part was omitting the extension of the media file: android.resource://com.mycompany/raw/song
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.