I'm making a little game on Android with Unity. And I use XML file to store different languages using System.Xml
. The language selection is done when I first start the game. When I run the game in Unity everything works fine - I select the language and the game goes on, but if I run it from Android nothing happens when I select the language. I connected my phone to the computer and looked at the game logs in cmd windows via adb.exe logcat
, and found this:
06-19 20:11:59.724 24342 24382 I Unity : jar:file:///data/app/com.eSnailStudio.CountTheNumber.Game-f0RdxK_Zfj2jXL2nqoA01A==/base.apk!/assets/Localization/Languages.xml
06-19 20:11:59.724 24342 24382 I Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
06-19 20:11:59.724 24342 24382 I Unity :
06-19 20:11:59.749 604 604 I ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
06-19 20:11:59.751 604 604 I ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
06-19 20:12:00.002 1857 1857 D KeyguardUpdateMonitor: handleTimeUpdate
06-19 20:12:00.021 24342 24382 E Unity : NotSupportedException: The URI prefix is not recognized.
06-19 20:12:00.021 24342 24382 E Unity : at System.Net.WebRequest.Create (System.Uri requestUri, System.Boolean useUriBase) [0x000ae] in <6b80e2850f1c48e6a227f0818ca6b227>:0
06-19 20:12:00.021 24342 24382 E Unity : at System.Net.WebRequest.Create (System.Uri requestUri) [0x00014] in <6b80e2850f1c48e6a227f0818ca6b227>:0
06-19 20:12:00.021 24342 24382 E Unity : at System.Xml.XmlDownloadManager.GetNonFileStream (System.Uri uri, System.Net.ICredentials credentials, System.Net.IWebProxy proxy, System.Net.Cache.RequestCachePolicy cachePolicy) [0x00000] in <b307146a71634627bcac16b7fdded4d2>:0
06-19 20:12:00.021 24342 24382 E Unity : at System.Xml.XmlDownloadManager.GetStream (System.Uri uri, System.Net.ICredentials credentials, System.Net.IWebProxy proxy, System.Net.Cache.RequestCachePolicy cachePolicy) [0x00022] in <b307146a71634627bcac16b7fdded4d2>:0
06-19 20:12:00.021 24342 24382 E Unity : at System.Xml.XmlUrlResolver.GetEntity (System.Uri absoluteUri, System.String role, System.Type ofObjectToReturn) [0x00032] in <b307146a71634627bcac16b7fdded4d2>:0
06-19 20:12:00.021 24342 24382 E Unity : at System.Xml.XmlTextReaderImpl.OpenUrlDelegate (System.Object xmlResolver) [0x0000c] in <b
The first line is the path to the android languages xml file, which I output through Debug.Log()
.
Through Debug.Log()
I also realized that the code stops on line xml.Load(Path);
in method below in the LanguageSystem
script:
public static void SetLanguage(string language)
{
var xml = new XmlDocument();
xml.Load(Path); // Here the code stops on Android
Strings = new Hashtable();
var element = xml.DocumentElement[language];
if (element != null)
{
var elemEnum = element.GetEnumerator();
while (elemEnum.MoveNext())
{
var xmlItem = (XmlElement)elemEnum.Current;
Strings.Add(xmlItem.GetAttribute("name"), xmlItem.InnerText);
}
}
else
{
Debug.LogError("The specified language does not exist: " + language);
}
}
I also opened the .APK file of the game through the archiver. Attached a photo below + photo of game game logs.
What is my mistake and how do I fix it?