- Home /
Android - WWW cannot escape '#' character in .jar path
Hi All,
I'm not sure if this is something that just isn't possible, or if there's some sort of bug with the WWW implementation for .jar files.
I have a .flac file in my streamingassets folder with the following name and JAR path File: F#1_GUITHIGHBRIDGEH_tk 50.flac File Path: jar:file:///data/app/com.cakewalk.testSynth-2/base.apk!/assets/Godin Artisan/HighH/F#1_GUITHIGHBRIDGEH_tk 50.flac
This file fails to load with the following exception: java.io.FileNotFoundException: JAR entry assets/Godin Artisan/HighH/F not found
So it seems like the '#' character causes the path to get cut off (I have no problem getting the data from a WWW if no '#' is present.) That seems fair, seeing as '#' is a special URL character. The output of my full file path, after calling WWW.EscapeURL, is jar%3afile%3a%2f%2f%2fdata%2fapp%2fcom.cakewalk.testSynth-2%2fbase.apk%21%2fassets%2fGodin+Artisan%2fHighH%2fF%231_GUITHIGHBRIDGEH_tk+50.flac
which seems... incorrect (and raises a java.net.MalformedURLException.) I also tried escaping just the file name, but that actually yields a StringIndexOutOfBounds exception.
So do .jar URLs need to be escaped differently? Or is it just bad practice on Android to use the '#' character? Our solution has been to write a python script to go through and replace any '#' characters, but we're dealing with musical samples so many "sharp" keys have a '#' in the file name.
I don't see this issue with spaces, for the record, which are another forbidden URL character, but I'm not sure what the best practice here is. Any advice will be welcomed gladly.
John
Answer by aditya · Apr 07, 2017 at 01:37 PM
First of all i don't think it is that # but that SPACE is culprit and you should not escape the the URL as whole just escape the file name .... see @Bunny83 's answer HERE ... Plus i m not much experienced with this URL thingy on android but on PCs these # are used to direct to a ID on a page so i think you should remove that #
Thanks for the response.
To test your answer, I replaced all '#' symbols with spaces and the file loaded fine on Android.
I think these .jar URLs are different from web URLs, so I'm not sure why the WWW class was re-purposed to read them (though I suspect this is the indirect cause of the bug.)
Your answer
Follow this Question
Related Questions
Clean Cache on Mobile 0 Answers
Could a Unity app running on Android install another APK on the device from the web? 1 Answer
unity3d www download of large texture mobile 0 Answers
Admob interstitial ad are slowing my game down 0 Answers
Porting simple game to android (Problem -> Controller) 0 Answers