Hey Everyone,
I’m struggling with a problem for a couple of days now, I’m making an app in which the user can take pictures with an AR layer
and save them to a gallery for mobile devices.
To keep track of these pictures I make xml files with all the info the user enters and save this and the picture (which I take through a ReadPixels because I don’t want my GUI in the picture) to the Application.persistentDataPath
This works perfectly in editor and iOS, but the Android version fails completely.
Every time I try to load something it returns the error :
*
java.net.MalformedURLException: java.lang.NullPointerException: Cannot find “!/”
*
The address that I’m trying to open is: * jar:file:///data/data/com.company.appName/files/name.txt *
but neither the png or the txt loads and I have no idea why. I think the saving works which just saves it with fileStreamer to
- /data/data/com.company.appName/files/name.txt * and I try loading it with a WWW, but that doesn’t seem to work.
It’s very confusing to find good information about the persistentdatapath and how to properly load from it and some say you have to add a prefix:
string path;
#if UNITY_EDITOR
path = "file:" + Application.persistentDataPath;
#elif UNITY_ANDROID
path = "jar:file://"+ Application.persistentDataPath;
#elif UNITY_IOS
path = "file:" + Application.persistentDataPath;
#else
//Desktop (Mac OS or Windows)
path = "file:"+ Application.persistentDataPath;
#endif
upon which I combine it with Path.Combine(path, fileName);
And while this is the case for iOS, it hasn’t worked so far I tried on Android and it’s driving me nuts. I’ve tried it without the prefix, I’ve tried it with “jar:file/”. Nothing seems to work, making me question this is even possible in Unity.
Is there something that has to be added to the manifest or changed in the player settings?
Please help, I’m losing too much time on this.