- Home /
Problems with loading asset bundles on android
Hi guys
As the title says I'm trying to load asset bundles on android. I did put my asset bundles inside StreamingAssets and I do see my directories containing the asset bundles inside Assets folder in the apk. However when I try to do
Directory.GetFiles("jar:file://" + Application.dataPath + "!/assets/", "*.unity3d", SearchOption.AllDirectories);
I get a DirectoryNotFoundException: Directory 'jar:file:/data/app/com.Company.ProductName-2.apk!/assets' not found.
Not sure what I'm missing. Help appreciated.
Thanks
Just to add its not like Directory.GetFiles doesn't work on anything. Cause if you do
Directory.GetFiles(Directory.GetCurrentDirectory()) it works just fine and prints all the results.
The problem is " jar:file:/data/app/com.Company.ProductName-2.apk" is path to jar (zip) file. And "/assets" is path within this zip file.
jar: protocol seems to not be supported by Directory nor File classes. But Unity's WWW does support it only for files. So even with WWW you can not get directory info.
You can't treat the strea$$anonymous$$g assets folder like it's part of the filesystem (on Android).
Why are you trying to list all the .unity3d files that are in there? If it's just so that you can load them, why not just put the filenames into the code?
Answer by aeroson · Oct 24, 2015 at 03:37 PM
I think its fixable by making and using custom Directory and File classes that support jar:file: protocol. Here have sources of such classes: https://gist.github.com/aeroson/4c90349d1f1c5a079744 they require Ionic.Zip.dll which you can download here: https://dotnetzip.codeplex.com/
Nonetheless on android it errors out: ArgumentException: Encoding name 'IBM437' not supported You need to unzip your .apk then copy over all I8N*.dll from Unity installation and zip it again, more info: http://answers.unity3d.com/questions/378005/ioniczipdll-does-not-work-in-build.html