parse-community / Parse-SDK-dotNET

Parse SDK for .NET, Xamarin, Unity.
http://parseplatform.org
Apache License 2.0
323 stars 260 forks source link

Unable to initialize Parse in Android #313

Closed FcoCGN closed 4 years ago

FcoCGN commented 5 years ago

When I executing Parse.initialize() in Android, the logcat shows:

E/Unity: UnauthorizedAccessException: Access to the path "/.local" is denied. at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x0004b] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.IO.Directory.CreateDirectory (System.String path) [0x00094] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.IO.DirectoryInfo.Create () [0x00000] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.Create() at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00023] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.IO.Directory.CreateDirectory (System.String path) [0x00094] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.IO.DirectoryInfo.Create () [0x00000] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.Create() at System.IO.Directory.CreateDirectoriesInternal (System.String path) [0x00023] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.IO.Directory.Crea

TobiasPott commented 5 years ago

Could you please provide some additional information about the context you are trying to use the Parse SDK for .NET in? What Framework do you use to get you application on android? Unity, Xamarin, anything else?

If it is Unity, please check the list of issues about support of Unity for the current master branch of this repository. Unity support is not available in the current state of the repository as it does not take Unity specific behaviour into account and removed references to Unity to make a clean restructure of the code base. https://github.com/parse-community/Parse-SDK-dotNET/pull/298

FcoCGN commented 5 years ago

Sorry. It's a Unity Project for Android. The Unity Version is 2018.3.8f1 and Parse-SDK-dotNET is a Master branch.

If I run project from the editor's mode in Unity, works perfectly, but if I run project in Android device, returns that error.

aikelb commented 5 years ago

I had this error too. Check AppInformation.cs around line 79 and change

public static string BasePath =>
#if UNITY || UNITY_EDITOR
#if UNITY_EDITOR
            Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
#else
            Application.persistentDataPath;
#endif
#else
            Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
#endif

for

public static string BasePath =>
#if UNITY || UNITY_EDITOR
#if UNITY_EDITOR
            Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
#else
            Application.persistentDataPath;
#endif
#else
            Application.persistentDataPath;
#endif

Otherwise the resulting path is ./local ....

That prevents the null reference exception but I can't make it reach the parse server. I have no clue why is this happening because I get no errors :(

TobiasPott commented 5 years ago

Hi @aikelb ,

I'm sorry I've missed this issue for several month now =/. If you didn't had any luck yet solving this issue on your own or are just curious on how to face the problem. Head over to https://github.com/TobiasPott/Parse-SDK-dotNET/tree/feature/recode-unity-support and try using a build version of that repository.

I've ran through all problems of initialization inside of Unity already and made a fork to integrate my fixes until the main repository is ready for extending the code with plug-in assemblies for different platforms like Unity. Remember cloning the linked feature branch (not the master) and build like I've mentiond in the ReadMe of that branch, all use of the assembly is the same as with the community repository.

If you have any problems please leave an issue on that repository. =)

HochulCL commented 4 years ago

Hi @TobiasPott , I am trying to build Parse.dll from your branch but I am having

/Parse-SDK-dotNET-feature-recode-unity-support/Parse/Internal/Utilities/AppInformation.cs(7,7): Error CS0246: The type or namespace name 'UnityEditor' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (Parse)

this error. Should I locate some file or project folder to somewhere else? I've try to put UnityEngine.dll and compile but then it gives another error again and again

TobiasPott commented 4 years ago

Oh I'm very sorry @HochulCL the branch I've linked above is outdated and I used it to rebuild our initial approach for support in Unity. Could you take a look at the https://github.com/TobiasPott/Parse-SDK-dotNET/tree/feature/implement-target-platform-configurations branch and read the Platforms.md file for more information about the configuration approach the branch provides?

I should take down the deprecated feature branch and delete it or redirect it to the above mentioned, as long as I didn't find the time to create and merge a pull request to the parse community repository. Sorry for that.

TobiasPott commented 4 years ago

The current master branch provides methodology to support Unity platforms and the referenced repository is no longer necessary. Please create a new issue if any new problems occur to discuss possible solutions.