Problems with json on android

Hey guys,

I wrote this component for multi language support. But it’s more or less a modified version of the unity tutorial script. In the Editor it’s working smooth but when I build the project and run it on mobile it crashes/get stuck at some point and I don’t know why.

    IEnumerator GetDataInAndroid(string fileName)
        {
            localizedText = new Dictionary<string, string>();
            string filePath = "";
            PreloaderText.text += "CreatingPath ";
            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                filePath = Path.Combine(Application.streamingAssetsPath + "/", fileName);
            }
            else if (Application.platform == RuntimePlatform.Android)
            {
                filePath = "jar:file://" + Application.dataPath + "!/assets" + "/" + fileName;
            }
            PreloaderText.text += "PathCreated ";
            string dataAsJson;
    
            if (filePath.Contains("://") || filePath.Contains(":///"))
            {
                //debugText.text += System.Environment.NewLine + filePath;
                Debug.Log("UNITY:" + System.Environment.NewLine + filePath);
                UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(filePath);
                yield return www.SendWebRequest();
                dataAsJson = www.downloadHandler.text;
//This fixes the problem. Scroll down to see why. :)
                dataAsJson = System.Text.Encoding.UTF8.GetString(www.downloadHandler.data, 3, www.downloadHandler.data.Length - 3);
            }
            else
            {
                dataAsJson = File.ReadAllText(filePath);
            }
            PreloaderText.text += "ReadingCompleted ";
            PreloaderText.text += dataAsJson;
            LocalizationData loadedData = JsonUtility.FromJson<LocalizationData>(dataAsJson);
    
            for (int i = 0; i < loadedData.items.Length; i++)
            {
                PreloaderText.text += i.ToString();
                localizedText.Add(loadedData.items_.key, loadedData.items*.value);*_

//Debug.Log(“KEYS:” + loadedData.items*.key);*
}

PreloaderText.text += “finished”;
//yield return new WaitForSeconds(1);
SceneManager.LoadScene(“Menu”);
}
PreloaderText is just an improvised console so I can sort of debug it on mobile. What I know is, that it runs until "ReadingCompleted " and in “dataAsJson” the correct string is written. So I guess the conversion from jar to string works and it gets stuck with the JsonUtility.
I’m running it with the 2017 version of unity because I wanted to work out the errors before I upgrade to 2018. Maybe thats the source for the error.
Thanks in advance for any suggestions.
EDIT: Json file
{“items”:
[{“key”:“Coal”,“value”:“Coalmine”},
{“key”:“Wood”,“value”:“Lumberyard”},
{“key”:“StationNorth”,“value”:“Station North”},
{“key”:“Ironore”,“value”:“Ironmine”},
{“key”:“Stone”,“value”:“Quarry”},
{“key”:“Harvester”,“value”:“Harvester”},
{“key”:“Wheels”,“value”:“Wheels”},
{“key”:“Planks”,“value”:“Planks”},
{“key”:“Harbour”,“value”:“Harbour”},
{“key”:“StationSouth”,“value”:“Station South”},{“key”:“Sand”,“value”:“Sandmine”},
{“key”:“Rubber”,“value”:“Rubber factory”},
{“key”:“Weed”,“value”:“Farm”},
{“key”:“Steel”,“value”:“Steel factory”},
{“key”:“Iron”,“value”:“Iron factory”},
{“key”:“Excavator”,“value”:“Excavator”},
{“key”:“ReinforcedConcrete”,“value”:“Reinforced Concrete”},
{“key”:“Get2ndWaggon”,“value”:“Get second Waggon”},
{“key”:“Refuel”,“value”:“Refuel”},
{“key”:“Upgrade”,“value”:“Upgrade”},
{“key”:“Buy”,“value”:“Buy”},
{“key”:“Select”,“value”:“Select”},
{“key”:“Selected”,“value”:“Selected”},
{“key”:“Next”,“value”:“Next”},
{“key”:“RefuelFirst”,“value”:“Refuel first”},
{“key”:“GO!”,“value”:“GO!”},
{“key”:“CurrentLevel”,“value”:“Current Level”},
{“key”:“DoYouWantToFillUp”,“value”:“Do you want to fill up”},
{“key”:“for”,“value”:“for”},
{“key”:“per”,“value”:“per”},
{“key”:“Close”,“value”:“Close”},
{“key”:“YouDontNeedToRefuel”,“value”:“You don’t need to refuel”},
{“key”:“YouHaventBoughtThisVehilceYet”,“value”:“You haven’t bought this vehicle yet”},
{“key”:“DoYouWantToUnlockThe2ndWgSlot”,“value”:“Do you want to unlock the second waggon slot for”},
{“key”:“No”,“value”:“No”},
{“key”:“Yes”,“value”:“Yes”},
{“key”:“YouDontHaveEnoughMoneyTPT”,“value”:“You don’t have enough money to purchace this”},
{“key”:“YouHaveReachedMaxLevel”,“value”:“You have reached max level”},
{“key”:“YouCantUpgradeThisVehicle”,“value”:“You can’t upgrade this vehicle”},
{“key”:“YouHaventReachedMaxLevelYet”,“value”:“You haven’t reached max level. You can upgrade”},
{“key”:“Back”,“value”:“Back”},
{“key”:“Input”,“value”:“Input”}]}

Well, maybe your json data (or whatever is actually read) can’t be converted to your “LocalizationData” type. Though you blindly adding the items to the dictionary. If there is a duplicate entry an exception will be thrown. You may want to wrap your code in a try catch and print / output the exception if any. Also you may want to add more yield return null in between. If for some reason something causes the app to hang you won’t see any update on the screen as you need at least one complete frame in order to see any changes.

To debug any issues you may want to use Debug.Log and logcat via USB debugging.