Aws-sdk-net: NullReferenceException on Unity 2017 iOS

Created on 21 Jul 2017  路  5Comments  路  Source: aws/aws-sdk-net

Expected Behavior

Should be able to initialise the AWS SDK and perform web requests

Current Behavior

NullReferenceException: A null value was found where an object instance was required.
  at Amazon.Runtime.Internal.UnityWebRequestWrapper..ctor () [0x00000] in <filename unknown>:0 
  at Amazon.AWSConfigs.set_HttpClient (HttpClientOption value) [0x00000] in <filename unknown>:0 
  at DownloadManager.Init () [0x00000] in <filename unknown>:0 
  at DownloadManager.get_instance () [0x00000] in <filename unknown>:0 
  at DownloadManager.Update () [0x00000] in <filename unknown>:0 
Rethrow as TypeInitializationException: The type initializer for 'Amazon.Runtime.Internal.UnityWebRequestWrapper' threw an exception.
  at Amazon.AWSConfigs.set_HttpClient (HttpClientOption value) [0x00000] in <filename unknown>:0 
  at DownloadManager.Init () [0x00000] in <filename unknown>:0 
  at DownloadManager.get_instance () [0x00000] in <filename unknown>:0 
  at DownloadManager.Update () [0x00000] in <filename unknown>:0 

Possible Solution


Steps to Reproduce (for bugs)

Create a simple scene and attach the AWS initialiser

Context

SDK is unusable

Unity

Most helpful comment

Yes for people visiting this thread and experience the same.

UnityEngine.Experimental.Networking is no longer a namespace for Unity 2017 onwards. (approx.)

Hence in your link.xml make sure you have
UnityEngine.Networking

Hence the head of link xml would be as follows
<assembly fullname="UnityEngine"> <type fullname="UnityEngine.Networking.UnityWebRequest" preserve="all" /> <type fullname="UnityEngine.Networking.UploadHandlerRaw" preserve="all" /> <type fullname="UnityEngine.Networking.UploadHandler" preserve="all" /> <type fullname="UnityEngine.Networking.DownloadHandler" preserve="all" /> <type fullname="UnityEngine.Networking.DownloadHandlerBuffer" preserve="all" /> </assembly>

as in this document -> https://github.com/aws/aws-sdk-net/blob/master/Unity.README.md#unity-sdk-fundamentals

All 5 comments

I'm also having a similar issue (immediately on app startup):

MissingMethodException: Method not found: 'Default constructor not found...ctor() of Amazon.Util.Internal.PlatformServices.NetworkReachability'.
  at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <filename unknown>:0 
  at Amazon.Util.Internal.PlatformServices.ServiceFactory..ctor () [0x00000] in <filename unknown>:0 
  at Amazon.Util.Internal.PlatformServices.ServiceFactory..cctor () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.UnityMainThreadDispatcher.ProcessRequests () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.UnityMainThreadDispatcher.Update () [0x00000] in <filename unknown>:0 
Rethrow as TypeInitializationException: The type initializer for 'Amazon.Util.Internal.PlatformServices.ServiceFactory' threw an exception.
  at Amazon.Runtime.Internal.UnityMainThreadDispatcher.ProcessRequests () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.UnityMainThreadDispatcher.Update () [0x00000] in <filename unknown>:0 

(Filename: currently not available on il2cpp Line: -1)

NullReferenceException: A null value was found where an object instance was required.
  at Amazon.Runtime.Internal.UnityMainThreadDispatcher.ProcessRequests () [0x00000] in <filename unknown>:0 
  at Amazon.Runtime.Internal.UnityMainThreadDispatcher.Update () [0x00000] in <filename unknown>:0 

There's also this.

Pardon me, I have no idea how to solve it - I'm just putting these here in case they might turn out helpful in debugging the root causes.

@ayushvora Your issue is looking more like you're missing the link.xml mentioned here in the Unity README

Thanks @haswalt , I'll check it out.

Yes for people visiting this thread and experience the same.

UnityEngine.Experimental.Networking is no longer a namespace for Unity 2017 onwards. (approx.)

Hence in your link.xml make sure you have
UnityEngine.Networking

Hence the head of link xml would be as follows
<assembly fullname="UnityEngine"> <type fullname="UnityEngine.Networking.UnityWebRequest" preserve="all" /> <type fullname="UnityEngine.Networking.UploadHandlerRaw" preserve="all" /> <type fullname="UnityEngine.Networking.UploadHandler" preserve="all" /> <type fullname="UnityEngine.Networking.DownloadHandler" preserve="all" /> <type fullname="UnityEngine.Networking.DownloadHandlerBuffer" preserve="all" /> </assembly>

as in this document -> https://github.com/aws/aws-sdk-net/blob/master/Unity.README.md#unity-sdk-fundamentals

How to setting Link xml in Xamarin form ios Project?

My code is:

Amazon.IotData.AmazonIotDataClient c = new Amazon.IotData.AmazonIotDataClient(
                    "https://xxxxx.iot.us-east-1.amazonaws.com", awsCredentials);

Errro is
Default constructor not found for type Amazon.Util.Internal.PlatformServices.NetworkReachability
I have the same problem, btw just happen in Run App in really iphone.
In iphone simulation won't meet the problem

Was this page helpful?
0 / 5 - 0 ratings