Page 1 of 1

Two issues: Access is denied and Sharing violation on path

Posted: Thu Oct 17, 2019 9:00 am
by teq
Hi there! My crashalytics shows me 2 type of issues related to ES3

1)Access to the path "/storage/emulated/0/Android/data/com.myapp.id/files/SaveData.es3" is denied (should i get WRITE_EXTERNAL_STORAGE permission ?)
I think it could be useful to show you my AndroidManifest

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<manifest
        xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.myapp.id"
        xmlns:tools="http://schemas.android.com/tools"
        android:installLocation="preferExternal"
        android:versionCode="2064"
        android:versionName="1.5.0">
    <supports-screens
            android:smallScreens="true"
            android:normalScreens="true"
            android:largeScreens="true"
            android:xlargeScreens="true"
            android:anyDensity="true"/>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

    <uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/>
    <uses-permission android:name="android.permission.BLUETOOTH" tools:node="remove"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>

    <uses-feature android:name="android.hardware.location" android:required="false"/>
    <uses-feature android:name="android.hardware.location.network" android:required="false"/>
    <uses-feature android:name="android.hardware.telephony" android:required="false"/>
    <uses-feature android:name="android.hardware.bluetooth" android:required="false"/>
    <uses-feature android:name="android.hardware.camera" android:required="false"/>
    <uses-feature android:name="android.hardware.camera.front" android:required="false"/>

    <application
            android:theme="@style/UnityThemeSelector"
            android:icon="@drawable/app_icon"
            android:label="@string/app_name"
            android:name="androidx.multidex.MultiDexApplication">
        <meta-data
                android:name="com.google.firebase.messaging.default_notification_icon"
                android:resource="@drawable/notify_icon_small"/>
        <meta-data android:name="com.google.firebase.messaging.default_notification_color"
                   android:resource="@color/colorAccent"/>
        <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true"/>
        <activity android:name="com.google.firebase.MessagingUnityPlayerActivity"
                  android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true"/>
        </activity>
        <service android:name="com.google.firebase.messaging.MessageForwardingService"
                 android:exported="false"/>
        <provider
                android:name="com.yasirkula.unity.UnitySSContentProvider"
                android:authorities="com.myapp.id"
                android:exported="false"
                android:grantUriPermissions="true"/>
    </application>
</manifest>
2)Sharing violation on path /storage/emulated/0/Android/data/com.myapp.id/files/SaveData.es3

Could you give me some advises how to solve these problems?
Thanks.

Re: Two issues: Access is denied and Sharing violation on pa

Posted: Thu Oct 17, 2019 1:54 pm
by Joel
Hi there,

The first issue is because Unity's Application.persistentDataPath is not writable. You would unfortunately need to contact Unity regarding this as the location and access of the persistent data path is controlled entirely at their end. I believe the main cause of this issue is usually because the user has denied the app permissions to write data.

With regards to the sharing violation, I've not seen this issue. Would it be possible to send more information regarding this? For example, is there a full stack trace? This will only usually happen if you're running Easy Save in multiple threads at once and trying to access the same file, or another piece of software is trying to access the file at the same time.

All the best,
Joel

Re: Two issues: Access is denied and Sharing violation on pa

Posted: Thu Oct 17, 2019 6:54 pm
by teq
Joel wrote:Hi there,

The first issue is because Unity's Application.persistentDataPath is not writable. You would unfortunately need to contact Unity regarding this as the location and access of the persistent data path is controlled entirely at their end. I believe the main cause of this issue is usually because the user has denied the app permissions to write data.

With regards to the sharing violation, I've not seen this issue. Would it be possible to send more information regarding this? For example, is there a full stack trace? This will only usually happen if you're running Easy Save in multiple threads at once and trying to access the same file, or another piece of software is trying to access the file at the same time.

All the best,
Joel
1)From docs we know that "Starting in API level 19, this permission is not required to read/write files in your application-specific directories returned by Context.getExternalFilesDir(String) and Context.getExternalCacheDir()." My devices:Nexus 5, PIxel 3a, Lenovo tab work well without any permissions granted. Just curios why this is happening with devices on Android 7,8,9 which have api bigger, than 19.
Image
Could you advice storing method with 100% reliability (from ES3 options) ?

BTW, today i've got new one

Code: Select all

Win32 IO returned 997. Path: /storage/emulated/0/Android/data/com.meappid.test/files/SaveData.es3

Re: Two issues: Access is denied and Sharing violation on pa

Posted: Fri Oct 18, 2019 6:59 am
by Joel
Hi there,

You might want to try setting the storage location to PlayerPrefs by going to Window > Easy Save 3 > Settings, and changing the save location from there. This will store the data in SharedPreferences on Android, which should be less susceptible to permission errors.

With regards to the errors, you would need to contact Unity regarding these as the specific file IO and Application.persistentDataPath is managed at their end, so they are the only ones able to debug this code, and will also be able to tell you about the permissions that they grant during their build process.

All the best,
Joel

Re: Two issues: Access is denied and Sharing violation on pa

Posted: Fri Oct 18, 2019 8:21 am
by teq
Joel wrote:Hi there,

You might want to try setting the storage location to PlayerPrefs by going to Window > Easy Save 3 > Settings, and changing the save location from there. This will store the data in SharedPreferences on Android, which should be less susceptible to permission errors.

With regards to the errors, you would need to contact Unity regarding these as the specific file IO and Application.persistentDataPath is managed at their end, so they are the only ones able to debug this code, and will also be able to tell you about the permissions that they grant during their build process.

All the best,
Joel
At this moment it is File->Persistent Data Path. What should i use? Player prefs? Will it be reliable for iOS? And how to transfer data from Persistent Data Path to PlayerPrefs for old users with data, already saved in Persistent Data Path?

Re: Two issues: Access is denied and Sharing violation on pa

Posted: Fri Oct 18, 2019 3:28 pm
by Joel
Hi there,

PlayerPrefs is the option you should use if you want the data to be stored there.

If you want to transfer the data from persistent data path to PlayerPrefs, you can do something along the lines of this:
var fileSettings = new ES3Settings();
fileSettings.location = ES3.Location.File;
var playerPrefsSettings = new ES3Settings();
playerPrefsSettings.location = ES3.Location.PlayerPrefs;

if(ES3.FileExists("myFile.es3", fileSettings))
{
    var data = ES3.LoadRawString("myFile.es3", fileSettings);
    ES3.SaveRaw(data, "myFile.es3", playerPrefsSettings);
}
All the best,
Joel

Re: Two issues: Access is denied and Sharing violation on pa

Posted: Sat Nov 02, 2019 7:11 pm
by teq
Thanks! If i am using this approach https://docs.moodkie.com/easy-save-3/es ... g-es3file/, will this access speed to param as fast as local var, so i can use it in cycle?

Re: Two issues: Access is denied and Sharing violation on pa

Posted: Mon Nov 04, 2019 8:07 am
by Joel
Hi there,

It will be as fast as accessing a Dictionary item, which should be perfectly fine to use in a cycle.

All the best,
Joel