UnauthorizedAccessException: Access to the path error on some devices

I have some users complaining that they are losing it’s save files on Android.

My Save Code

        var serializedObject = JsonConvert.SerializeObject(SaveData);
        var savePath = Path.Combine(Application.persistentDataPath, "save.sav");
        var bytes = Encoding.UTF8.GetBytes(serializedObject);
        File.WriteAllBytes(savePath, bytes);

Error Message :
UnauthorizedAccessException: Access to the path “/storage/emulated/0/Android/data/com.sevensails.queensgarden/files/save.sav” is denied.

Stack Trace :

System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options)
System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
(wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int)
System.IO.File.Create (System.String path, Int32 bufferSize)
System.IO.File.Create (System.String path)
System.IO.File.WriteAllBytes (System.String path, System.Byte[] bytes)

Using Unity Game Performance Monitor, I was able to find more info about the devices where this error did occurs:

  • unique_device_models:[“ARMv7 VFPv3 NEON”]

  • 0:“ARMv7 VFPv3 NEON”

  • unique_graphics_devices:[“VideoCore IV HW”, “NVIDIA Tegra 3”, “PowerVR SGX 540”, “GC1000 core”]

  • 0:“VideoCore IV HW”

  • 1:“NVIDIA Tegra 3”

  • 2:“PowerVR SGX 540”

  • 3:“GC1000 core”

  • unique_platforms:[“Android OS 4.2.2 / API-17 (JDQ39/I9082XXUBMK5)”,…]

  • 0:“Android OS 4.2.2 / API-17 (JDQ39/I9082XXUBMK5)”

  • 1:“Android OS 4.2.1 / API-17 (JOP40D/WW_epad-10.6.1.27.5-20130902)”

  • 2:“Android OS 4.2.2 / API-17 (JDQ39/P5100XXDMJ2)”

  • 3:“Android OS 4.2.2 / API-17 (JDQ39/T110XXUANI7)”

  • 4:“Android OS 4.2.2 / API-17 (JDQ39/T110UEUANK2)”

Please… Is there anything I can look for? Is “ARMv7 VFPv3 NEON” a unique device, where I can find more info about it?

Have you found any solution for this problem? We are having a few isolated cases with this issue, seems to be working fine in any other device we tested with tho.

No yet! I’m waiting for some “magic fix” from Unity! I could not reproduce the error, but I have a lot of them reported on Performance Reporting.

any solutions for this?? I have the same error. Started haveing this after unity upgrade to version 2018.3.0f2 and doing gradle build. (I dont know if this if of some importance, but to do a gradle build I had to comment out a line in my AndroidManifest.xml: otherwise the app would not build)