amazon-archives / aws-sdk-unity

ARCHIVED: The aws sdk for unity is now distributed as a part of aws sdk for dotnet:
https://github.com/aws/aws-sdk-net
Other
105 stars 43 forks source link

NullReferenceException: Object reference not set to an instance of an object #103

Closed Bestlis closed 8 years ago

Bestlis commented 8 years ago

Hello!

I try to integrate DynamoDB into unity game. Unity version 5.2.1f1 AWS 2.1.0.0

Here is my code:

CognitoAWSCredentials _credentials = new CognitoAWSCredentials("us-east-1:xxxxxxxxxxxxxx", RegionEndpoint.USEast1); AmazonDynamoDBClient client = new AmazonDynamoDBClient(_credentials, RegionEndpoint.USEast1);

DynamoDBContext _context = new DynamoDBContext(client);

print("CONTEXT: " + _context);

//пытаемся получить данные пользователя по ключу _context.LoadAsync(BestlisAnalyticManager.GetDeviceId(), (result) => { print("RESULT " + result); }, null);

As the result I get this responce

I/Unity ( 3783): recieved successful response I/Unity ( 3783): I/Unity ( 3783): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe bugBindings.gen.cpp Line: 64) I/Unity ( 3783): I/Unity ( 3783): {"Credentials":{"AccessKeyId":"ASIAIZMWUM4RP6IBUERA","Expirat ion":1.446809463E9,"SecretKey":"ltFPVjJz1trCkMDOAiicyN0IOx4AQtYM0NB8knOR","Sessi onToken":"AQoDYXdzEFwasAXYXBetmYFHGQVdua7354uHklxDdRBxT4hYm0cdr9OZEKZkxqdM0rYWEN y97K5SIOVuhvji8R92fFogI4TuCVds0s4VGIpox3IYqq6inNZdx3aBObwRJdwfYP7SuLVAbRI7YwIYfP pI73f81IWUN3C5cZeizXNvChJjF5qYX273zGRrORXDKek6ktNDyKEHK2Htg1gDIyar5kP47udqYPcrMv Wa22C+BLpID2oxxvTdo6ZCkQTDrVXnc7NI7K3hABbQr3U6mW1WLEFGPr8xQ4/lxR3m9xD5+yTkktky4b eIQizdJBfNEONjTLhFdwtzt8bvlEBOAe1W5hfG2wMnZeX5ipyHBsw4MitEVNM15EohmB4RiIowbC8t3i bEvt5FlyvWclPmFtEF8bQ8o1577EuUD3JDwT3K/RFt5p3puVFfHOrPvWfsesV3+q2vP9U/v6IvOyLeCJ xu/HS3Hqov1r8dYDbUyTeZii4AhTcdqGakDzT6JDz2bzSxV9p7siTJLIT9QY0ElwWN7UMXwO926guN+t sURjlr4vXQ1BXtd+sAsvnEGc+cqA32QvRvL8byxvLLTLaMnvjK9EKyiYcKj311FGJgtC6Wh+fRagTtcc pkgE//bUlokdFiTFbGj01SSfNWz0gCeRQCJu0UaxYrBq+wwBEVzIgb0pZMvg+cTgBwTsYvPFNG53epFz kHFbyLV3k7L+jVKxEIuxeyCyVxs0ZktrWgeDKukLqrhUX75+NtUMTindnEBfOj3m8+Gfsf/8QdBnNJnx FfIIAg9u3kTwvysldsU+v5vq7F6K6iyIcCLH0lzQ8J2Clb+5ba45O0AdmNxg7ku0phTD8sCXCr7A5YXW wd I/Unity ( 3783): Status = OK I/Unity ( 3783): I/Unity ( 3783): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe bugBindings.gen.cpp Line: 64) I/Unity ( 3783): I/Unity ( 3783): Received response (truncated to 4096 bytes): [{"Credentials": {"AccessKeyId":"ASIAIZMWUM4RP6IBUERA","Expiration":1.446809463E9,"SecretKey":"lt FPVjJz1trCkMDOAiicyN0IOx4AQtYM0NB8knOR","SessionToken":"AQoDYXdzEFwasAXYXBetmYFH GQVdua7354uHklxDdRBxT4hYm0cdr9OZEKZkxqdM0rYWENy97K5SIOVuhvji8R92fFogI4TuCVds0s4V GIpox3IYqq6inNZdx3aBObwRJdwfYP7SuLVAbRI7YwIYfPpI73f81IWUN3C5cZeizXNvChJjF5qYX273 zGRrORXDKek6ktNDyKEHK2Htg1gDIyar5kP47udqYPcrMvWa22C+BLpID2oxxvTdo6ZCkQTDrVXnc7NI 7K3hABbQr3U6mW1WLEFGPr8xQ4/lxR3m9xD5+yTkktky4beIQizdJBfNEONjTLhFdwtzt8bvlEBOAe1W 5hfG2wMnZeX5ipyHBsw4MitEVNM15EohmB4RiIowbC8t3ibEvt5FlyvWclPmFtEF8bQ8o1577EuUD3JD wT3K/RFt5p3puVFfHOrPvWfsesV3+q2vP9U/v6IvOyLeCJxu/HS3Hqov1r8dYDbUyTeZii4AhTcdqGak DzT6JDz2bzSxV9p7siTJLIT9QY0ElwWN7UMXwO926guN+tsURjlr4vXQ1BXtd+sAsvnEGc+cqA32QvRv L8byxvLLTLaMnvjK9EKyiYcKj311FGJgtC6Wh+fRagTtccpkgE//bUlokdFiTFbGj01SSfNWz0gCeRQC Ju0UaxYrBq+wwBEVzIgb0pZMvg+cTgBwTsYvPFNG53epFzkHFbyLV3k7L+jVKxEIuxeyCyVxs0ZktrWg eDKukLqrhUX75+NtUMTindnEBfOj3m8+Gfsf/8QdBnNJnxFfIIAg9u3kTwvysldsU+v5vq7F6K6iyIcC LH I/Unity ( 3783): Request metrics: {"properties":{"AsyncCall":"False","ServiceN ame":"Amazon.CognitoIdentity","ServiceEndpoint":"https://cognito-identity.us-eas t-1.amazonaws.com/","MethodName":"GetCredentialsForIdentityRequest","RequestSize ":"63","StatusCode":"OK","BytesProcessed":"1156","AWSRequestID":"7b23c274-8471-1 1e5-9e8f-9f8cd577359f"},"timings":{"HttpRequestTime":20832.3334,"ResponseUnmarsh allTime":180.4366,"ResponseProcessingTime":217.2166,"ClientExecuteTime":21608.23 67},"counters":{}} I/Unity ( 3783): I/Unity ( 3783): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe bugBindings.gen.cpp Line: 64) I/Unity ( 3783): I/Unity ( 3783): NullReferenceException: Object reference not set to an instan ce of an object I/Unity ( 3783): at Amazon.Util.CryptoUtilFactory+CryptoUtil.ComputeSHA256Ha sh (System.Byte[] data) [0x00000] in :0 I/Unity ( 3783): at Amazon.Runtime.Internal.Auth.AWS4Signer.SetRequestBodyHa sh (IRequest request) [0x00000] in :0 I/Unity ( 3783): at Amazon.Runtime.Internal.Auth.AWS4Signer.SignRequest (IRe quest request, Amazon.Runtime.ClientConfig clientConfig, Amazon.Runtime.Internal .Util.RequestMetrics metrics, System.String awsAccessKeyId, System.String awsSec retAccessKey) [0x00000] in :0 I/Unity ( 3783): at Amazon.Runtime.Internal.Auth.AWS4Signer.Sign (IRequest r equest, Amazon.Runtime.ClientConfig clientConfig, Amazon.Runtime.Internal.Util.R equestMetrics metrics, System.String awsAccessKeyId, System.String awsSecretAcce ssKey) [0x00000] in :0 I/Unity ( 3783): at Amazon.Runtime.Internal.Signer.SignRequest (IRequestCont ext requestContext) [0x00000] in :0 I/Unity ( 3783): at Amazon.Runtime.Internal.Signer.PreInvoke (IExecutionCo E/Unity ( 3783): NullReferenceException making request DescribeTableRequest to https://dynamodb.us-east-1.amazonaws.com/. Attempt 1. E/Unity ( 3783): E/Unity ( 3783): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe bugBindings.gen.cpp Line: 64) E/Unity ( 3783): I/Unity ( 3783): Request metrics: {"properties":{"AsyncCall":"False"},"timings ":{"CredentialsRequestTime":0.0733,"RequestSigningTime":256.8967,"ClientExecuteT ime":535.9333},"counters":{}} I/Unity ( 3783): I/Unity ( 3783): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe bugBindings.gen.cpp Line: 64) I/Unity ( 3783): I/Unity ( 3783): NullReferenceException: Object reference not set to an instan ce of an object I/Unity ( 3783): at Amazon.Util.CryptoUtilFactory+CryptoUtil.ComputeSHA256Ha sh (System.Byte[] data) [0x00000] in :0 I/Unity ( 3783): at Amazon.Runtime.Internal.Auth.AWS4Signer.SetRequestBodyHa sh (IRequest request) [0x00000] in :0 I/Unity ( 3783): at Amazon.Runtime.Internal.Auth.AWS4Signer.SignRequest (IRe quest request, Amazon.Runtime.ClientConfig clientConfig, Amazon.Runtime.Internal .Util.RequestMetrics metrics, System.String awsAccessKeyId, System.String awsSec retAccessKey) [0x00000] in :0 I/Unity ( 3783): at Amazon.Runtime.Internal.Auth.AWS4Signer.Sign (IRequest r equest, Amazon.Runtime.ClientConfig clientConfig, Amazon.Runtime.Internal.Util.R equestMetrics metrics, System.String awsAccessKeyId, System.String awsSecretAcce ssKey) [0x00000] in :0 I/Unity ( 3783): at Amazon.Runtime.Internal.Signer.SignRequest (IRequestCont ext requestContext) [0x00000] in :0 I/Unity ( 3783): at Amazon.Runtime.Internal.Signer.PreInvoke (IExecutionCo E/Unity ( 3783): NullReferenceException making request DescribeTableRequest to https://dynamodb.us-east-1.amazonaws.com/. Attempt 1. E/Unity ( 3783): E/Unity ( 3783): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe bugBindings.gen.cpp Line: 64) E/Unity ( 3783): I/Unity ( 3783): Request metrics: {"properties":{"AsyncCall":"False"},"timings ":{"CredentialsRequestTime":0.16,"RequestSigningTime":4.3767,"ClientExecuteTime" :51.0633},"counters":{}} I/Unity ( 3783): I/Unity ( 3783): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe bugBindings.gen.cpp Line: 64) I/Unity ( 3783): I/Unity ( 3783): RESULT Amazon.DynamoDBv2.AmazonDynamoDBResult`1[DynamoDBScrip t+UserData]

Why I get NullReferenceException?

Thanks!

johnnyhoffman commented 8 years ago

Hi. I am not able to reproduce your error. Can you provide information about relationship between the UserData class you have defined and the table you are trying to load from? Is this failing in the Unity Editor, or just the device?

Bestlis commented 8 years ago

Set PlayerSettings -> Other Settings -> Stripping Level to Use micro ms corlib It is failing on Android device.

johnnyhoffman commented 8 years ago

Using micro mscorlib strips assemblies that are required by the core of the AWS SDK, which is why you are the NullReferenceException. At this time, we don't provide a way to disable stripping for only the assemblies required by the SDK. Noting this as a feature request.

shiraz88 commented 8 years ago

Thanks for the fix as well - hoping this will get addressed in future AWS Unity SDK update.

karthiksaligrama commented 8 years ago

related to #80 tracking this feature request there