- Home /
Reading XML working in my computer but not in my Android phone
I changed the following
..
Type[] itemTypes = { typeof(Equipment), typeof(Weapon), typeof(Consumeble), typeof(Jevelary) };
XmlSerializer serializer = new XmlSerializer(typeof (ItemContainer), itemTypes);
TextReader textReader = new StreamReader (Application.streamingAssetsPath + "/" + "Items.xml");
itemContainer = (ItemContainer)serializer.Deserialize (textReader);
textReader.Close ();
..
into
..
TextAsset asset = Resources.Load ("Itemss") as TextAsset;
Stream s = new MemoryStream (asset.bytes);
BinaryReader br = new BinaryReader (s);
XmlSerializer serializer = new XmlSerializer(typeof (ItemContainer), itemTypes);
StreamReader sr = new StreamReader (s);
itemContainer = (ItemContainer)serializer.Deserialize (sr);
..
but it doesnt work on all android devices, it doesnt work on S9 curve, could anybody help me how to fix this please, noob here :)
Answer by fink93 · Feb 04, 2019 at 03:28 PM
On Android, the files are contained within a compressed .jar file (which is essentially the same format as standard zip-compressed files). This means that if you do not use Unity’s WWW class to retrieve the file, you need to use additional software to see inside the .jar archive and obtain the file.
I am not sure how to do this :/, can someone please help me.
Answer by Kastar-Troy · Dec 18, 2019 at 06:03 AM
Similar problems here, we need some help!
https://answers.unity.com/questions/1685428/android-xml-serialization-and-web-services-trying.html