- Home /
Unable to write files to storage [SD or Internal] when building with IL2CPP in unity 2018.1.0b4
When I build with IL2CPP in unity 2018.1.0b4 and try to write a file to the storage nothing happens! here's my code...
using UnityEngine;
using System.IO;
using Newtonsoft.Json;
public class Serializer : MonoBehaviour
{
public void Serialize ()
{
string json = JsonConvert.SerializeObject(saveData, Formatting.Indented);
File.WriteAllText(Path.Combine(Application.persistentDataPath, "savegameData.json"), json);
}
}
Are you sure that your app has the right permissions set? I haven't used IL2CPP with Android yet. I guess you talk about Android? If not you may want to edit your question and clarify. Unity usually detects automatically which permissions are needed based on what classes / methods are used. It's possible that this doesn't work / doesn't work quite right. Though internal storage access doesn't require any permissions and should always work. Have you tried showing the content of your persistentDataPath on screen for debugging purposes.
$$anonymous$$eep in $$anonymous$$d that beta releases are not ment to be used in production as they may contain experimental stuff and may contain bugs, hence it's a beta version.
Answer by dediub · Nov 25, 2018 at 10:54 PM
The same to me man. AND NOBODY HELPS!, there is nothing out there that can help us. I have done all that they say and it never Works. I have almost the same code. I had tried with persistentDataPath, Environment.Personal, dataPath with the same behaviour: EDITOR WORKS AND THE BUILD NOT.
Good work UNITY, I have never seen such error like this, NEVER!.
I have the solution man!!!, try to watch your file: User\AppData\LocalLow\Company Name\Game name\output_log.txt Here you will find the exception that ruins your game. $$anonymous$$y error was one Json$$anonymous$$apper exception. FIXED!! LUC$$anonymous$$