Support Topics Documentation Slack YouTube Blog

Unity SDK play & compile errors

Client SDK (REST / Android / Objective-C / Swift / JS )

BackendlessSDK-UnityPackage-5.5.1.unitypackage

Application ID

7E819124-27B5-85D2-FF77-9FB70FF33800

After import the BackendlessSDK-UnityPackage-5.5.1.unitypackage into Unity 2019.3.14f1 and set the application ID and Api Key in Backendless plugin. I receive the error:

Screen Shot 2020-06-24 at 10.18.49

MissingFieldException: Field 'Quobject.EngineIoClientDotNet.Modules.LogManager.Enabled' not found.
BackendlessPlugin.Awake () (at Assets/BackendlessSDK/BackendlessPlugin.cs:101)

The line 101:

Backendless.InitApp(applicationId, APIKey );

Also, I tried to compile and I got these errors:

Fatal error in Unity CIL Linker
Mono.Linker.MarkException: Error processing method: ‘System.Void BackendlessAPI.Backendless::InitApp(System.String,System.String)’ in assembly: ‘Backendless.dll’ —> Mono.Cecil.ResolutionException: Failed to resolve System.Boolean

I already deleted the library folder to force the reload all dependencies, but I got the same.

Few weeks ago I decided not to use the Unity SDK, but I need Real-Time Database, please, Can help me to solve this?

Hi @Dario_Castaneda,

I am looking into this problem. Will report my findings shortly.

Regards,
Mark

Hi @Dario_Castaneda,

We prepared a new custom Unity package (v6.0.0). It is available in our git repo:

Please install the latest package and see if it works for you.

I tested all possible combinations and the Backendless plugin worked for all:

  • .NET Standard 2.0/Mono
  • .NET 4.x/Mono
  • .NET Standard 2.0/IL2CPP
  • .NET 4.x/IL2CPP

Kind regards,
Mark

Thank you for your quick response, let me try with this new version

Hi Mark,

The SKD works in the Unity player without problem, also compiles ok, but when I run the app in Android I got this error:

06-24 14:02:56.911 27026 27273 E Unity   : NullReferenceException: Object reference not set to an instance of an object.
06-24 14:02:56.911 27026 27273 E Unity   :   at Weborb.Client.HttpEngine.SendHttpRequest[T] (Weborb.V3Types.V3Message v3Msg, System.Collections.IDictionary requestHeaders, System.Collections.IDictionary httpHeaders, Weborb.Client.Responder`1[T] responder, Weborb.Client.AsyncStreamSetInfo`1[T] asyncStreamSetInfo) [0x00000] in <00000000000000000000000000000000>:0 
06-24 14:02:56.911 27026 27273 E Unity   :   at System.Threading.WaitCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
06-24 14:02:56.911 27026 27273 E Unity   :   at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
06-24 14:02:56.911 27026 27273 E Unity   :   at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
06-24 14:02:56.911 27026 27273 E Unity   :   at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0 
06-24 14:02:56.911 27026 27273 E Unity   : System.UnhandledExceptionEventHand
06-24 14:02:56.911 27026 27275 E Unity   : NullReferenceException: Object reference not set to an instance of an object.
06-24 14:02:56.911 27026 27275 E Unity   :   at Weborb.Client.HttpEngine.SendHttpRequest[T] (Weborb.V3Types.V3Message v3Msg, System.Collections.IDictionary requestHeaders, System.Collections.IDictionary httpHeaders, Weborb.Client.Responder`1[T] responder, Weborb.Client.AsyncStreamSetInfo`1[T] asyncStreamSetInfo) [0x00000] in <00000000000000000000000000000000>:0 
06-24 14:02:56.911 27026 27275 E Unity   :   at System.Threading.WaitCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
06-24 14:02:56.911 27026 27275 E Unity   :   at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
06-24 14:02:56.911 27026 27275 E Unity   :   at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
06-24 14:02:56.911 27026 27275 E Unity   :   at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <00000000000000000000000000000000>:0 
06-24 14:02:56.911 27026 27275 E Unity   : System.UnhandledExceptionEventHand
06-24 14:02:57.407 27026 27272 I Unity   : Backendless BackendlessFault. Code: Internal client exception, Message: Default constructor not found for type Weborb.V3Types.ErrMessage
06-24 14:02:57.407 27026 27272 I Unity   : BackendlessAPI.Async.ErrorHandler:Invoke(BackendlessFault)
06-24 14:02:57.407 27026 27272 I Unity   : BackendlessAPI.Async.ErrorHandler:Invoke(BackendlessFault)
06-24 14:02:57.407 27026 27272 I Unity   : Weborb.Client.ErrorHandler:Invoke(Fault)
06-24 14:02:57.407 27026 27272 I Unity   : Weborb.Client.HttpEngine:ProcessAMFResponse(IAsyncResult)
06-24 14:02:57.407 27026 27272 I Unity   : System.AsyncCallback:Invoke(IAsyncResult)
06-24 14:02:57.407 27026 27272 I Unity   : System.Net.SimpleAsyncCallback:Invoke(SimpleAsyncResult)
06-24 14:02:57.407 27026 27272 I Unity   : System.Net.HttpWebRequest:SetResponseData(WebConnectionData)
06-24 14:02:57.407 27026 27272 I Unity   : System.AsyncCallback:Invoke(IAsyncResult)
06-24 14:02:57.407 27026 27272 I Unity   : System.Action:Invoke()
06-24 14:02:57.407 27026 27272 I Unity   : System.Threading.ContextCallback:Invoke(Object)
06-24 14:02:57.407 27026 27272 I Unity   : System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
06-24 14:02:57.407 27026 27272 I Unity   : System.Threading.Tasks.AwaitTaskContinuation:RunCallback(ContextCallback, Object, Task&)
06-24 14:02:57.407 27026 27272 I Unity   : System.Threading.Tasks.Task:FinishContinuations()
06-24 14:02:57.407 27026 27272 I Unity   : System.Threading.Tasks.Task`1:TrySetResult(TResult)
06-24 14:02:57.407 27026 27272 I Unity   : System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Create()
06-24 14:02:57.407 27026 27272 I Unity   : Mono.Net.Security.<>c__DisplayClass66_0:<

The code i’ve used for this test is:

        Backendless.InitApp("XXXXXX", "XXXXXXXX");
        AsyncCallback <BackendlessUser> callback = new AsyncCallback<BackendlessUser>(
        user =>
        {
            print("User logged in. Assigned ID - " + user.ObjectId);
            Dictionary<string, object> props = user.Properties;
            foreach (KeyValuePair<string, object> pair in props)
                print(String.Format("Property: {0} - {1}", pair.Key, pair.Value));
        },
        fault =>
        {
            print(fault.ToString());
        });

        Backendless.UserService.Login("user", "password", callback);

Do you run it in an emulator or a physical device? What version of Android do you target?

In a physical device, the minimum versión is API Level 23, the target API Level is 29, and my device have Android 10.

Would you happen to have a test project you could share with me? It will be very helpful for me to reproduce the problem. If not, that’s ok, I will try to put one together myself.

Sure, give me a moment

Hi Mark,

test.zip (2.2 MB)

This app reproduces the error:

Thank you !

Hi Dario,

Need your help with Unity… I see the code in startup.cs… Is that script attached to a game object? I do not see any game objects in the scene. So my question is what makes that code run? Also, the sample project does not seem to be using the BackendlessPlugin.

I ran the project in the Unity player and I do not see any log output at all. What am I missing?

Cheers,
Mark

Hi,

Yes, the script is attached to the canvas object, my app is not a game, is a app with Wikitude plugin.

The code run when the screen is created, you can see the output in the console window:

I remove the plugin because I noticed that the error is generated twice (one for the plugin and the other by the code)

Hi,

Here is the same code, with BackendlessPlugin attached to the screen. I get the same error.

test.zip (2.2 MB)

I do “Build and Run” from Unity, I see it is successfully built, but I cannot figure out where I can see the logs from the app running on the device. Any clues for where I should look?

Yes,

In a terminal window execute: adb logcat -s Unity DEBUG

The app must be runing in your phone

Hi Dario,

I changed the “Scripting Backend” to “Mono” and the project worked. The reason it needs to be Mono is because with IL2CPP, the build strips out a lot of code rather unintelligently and because of that some things break. It is impossible to disable “Managed Stripping Level” when the scripting backend is IL2CPP:

Regards,
Mark

Here’s a workaround in you need to use IL2CPP as the scripting backend:

Create a file called link.xml with the following contents:

<linker>
  <!--Preserve an entire assembly-->
  <assembly fullname="Backendless" preserve="all"/>
</linker>

Place that file into the Assets directory. Once you build, all the important parts of the Backendless SDK will be preserved and the project also runs just fine.

Hope this helps.

Cheers,
Mark

Thank you Mark,

Yes, I`ve changed the Scripting Backend, and the app works, but I knew Google Play requires ARM64, with mono I can’t build to 64bits. IL2CPP allows to create 64bits versions

https://developer.android.com/distribute/best-practices/develop/64-bit

ohhh!, let me try …

Thank you Mark

I did some test and I can get the user info, but I still have one error:

E Unity   : NullReferenceException: Object reference not set to an instance of an object.
E Unity   :   at Weborb.Client.HttpEngine.SendHttpRequest[T] (Weborb.V3Types.V3Message v3Msg, System.Collections.IDictionary requestHeaders, System.Collections.IDictionary httpHeaders, Weborb.Client.Responder`1[T] responder, Weborb.Client.AsyncStreamSetInfo`1[T] asyncStreamSetInfo) [0x00000] in <00000000000000000000000000000000>:0 
E Unity   :   at Weborb.Client.HttpEngine+<>c__DisplayClass5_0`1[T].<SendRequest>b__0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
E Unity   :   at System.Threading.WaitCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
E Unity   :   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
E Unity   :   at System.Threading.ContextCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
E Unity   :   at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContex

I don’t know if in the future will be a issue…

Last question …

Using the non-blocking method I noticed I cant access to other methods in the class or any game object referencied from the inspector, I got the error: Backendless BackendlessFault. Code: Internal client exception, Message: get_isActiveAndEnabled can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
How can I invoke other class methods from AsyncCallback? The only way I found is create a property and check if its value changed (from update function) and call other function to process the data.

Last but not least … I really appreciate the help that you provide to me, this confirm that I took the right decision for backend service… thanks so much.