aws / aws-sdk-net

The official AWS SDK for .NET. For more information on the AWS SDK for .NET, see our web site:

Home Page:http://aws.amazon.com/sdkfornet/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AWS SDK not working on Android build

santoshParihar opened this issue · comments

Describe the bug

Hi, I am using AWS SDK to send a file to S3 bucket.
I have integrated s3 package only to unity editor.
It works fine in editor, as i can send the file to s3 bucket.

However when i build the apk, It doesn't run and throws error.

My system : using Unity 2020.3.48f1 , IL2CPP and dotnet 4. also tried dotnet 2 , still same issue.
I am using unity as a library where unity is exported in android studio and then make an android build.

I tried the unity build option also, but same issue.

My Link.xml file :

exception :

2024-03-20 12:30:25.278 20804-20828/? E/Unity: ArgumentException: Object of type 'System.Object[]' cannot be converted to type 'UnityEngine.AndroidJavaObject[]'.
at System.RuntimeType.CheckValue (System.Object value, System.Reflection.Binder binder, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) [0x00000] in <00000000000000000000000000000000>:0
at System.Reflection.MonoMethod.ConvertValues (System.Reflection.Binder binder, System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) [0x00000] in <00000000000000000000000000000000>:0
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <00000000000000000000000000000000>:0

Then

2024-03-19 12:58:22.179 17823-17958/com.winzo.gold.stag E/Unity: MissingMethodException: Default constructor not found for type Amazon.Util.Internal.PlatformServices.NetworkReachability
at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0
at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Util.Internal.PlatformServices.ServiceFactory..ctor () [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Util.Internal.PlatformServices.ServiceFactory..cctor () [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Util.Internal.InternalSDKUtils.BuildUserAgentString (System.String serviceSdkVersion) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.CognitoIdentity.AmazonCognitoIdentityConfig..cctor () [0x00000] in <00000000000000000000000000000000>:0
at Amazon.CognitoIdentity.AmazonCognitoIdentityClient..ctor (Amazon.Runtime.AWSCredentials credentials, Amazon.RegionEndpoint region) [0x00000]

Expected Behavior

It should not throw errors on android build, it should run fine, as it is working on unity editor.

Current Behavior

Working fine in unity editor but not on android build.

Reproduction Steps

No special steps. Just import the s3 package in unity project and run your own sample example on android build.

Possible Solution

IDK

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

AWSSDK.S3.3.3.113.2

Targeted .NET Platform

.NET 4

Operating System and version

MacOS

@santoshParihar Good morning. Thanks for opening the issue. Could you please share the below information:

  • Have you followed instructions at Special considerations for Unity support to setup your Unity project? (I do see there is another documentation link What is the AWS Mobile SDK for Unity?, but it has a banner at the top that it references the archived version of the Mobile SDK for Unity.)
  • Could you enable verbose logging using the below code and see if you are able to collect verbose logs (I'm unsure how these would be available on actual Android device):
    Amazon.AWSConfigs.LoggingConfig.LogResponses = Amazon.ResponseLoggingOption.Always;
    Amazon.AWSConfigs.LoggingConfig.LogTo = Amazon.LoggingOptions.Console;
    Amazon.AWSConfigs.AddTraceListener("Amazon", new System.Diagnostics.ConsoleTraceListener());
  • You mentioned the target platform as .NET 4 and platform as MacOS. Are you using Mono? What is the exact .NET Framework version? The link I shared mentions that it needs to target .NET Standard 2.0.

Thanks,
Ashish

Hi @ashishdhingra , Good Afternoon,
Yes, I followed the special considerations to set up the project.

Thanks for looking into this. I've prepared a detailed document on Google Docs outlining the problem, along with the logs and relevant SDK configurable code.

https://docs.google.com/document/d/1ck_nSuPZbmmYT2ysyRjvMDpc4OClYwyquh5LsZLSEtI/edit?usp=sharing

If you could take some time to review the provided information and provide your insights, it would be immensely helpful.

Thank you very much for your attention to this matter. Please let me know if you need any further clarification or assistance.

Hi @santoshParihar,

Thank you so much for providing more details on this issue. Can you check if you get the error after taking below steps?

  • Upgrade the AWS SDK for .NET to version 3.5 or above. Based on S3 package version, I believe you are on version 3.3. Basically, kindly check with latest assemblies.
  • Disable code stripping for AWSSDK S3 assembly by adding <assembly fullname="AWSSDK.S3" preserve="all"/> in the linker file (link.xml) you are using. I do not see this in the document you shared.

If you still get the error, can you kindly share a sample unity project that can reproduce this issue. It would be of great help if you can mention the steps you took for error reproduction.

Thanks again for your cooperation in helping to reproduce this issue.

Regards,
Chaitanya

Hi @bhoradc , I am sharing the sample project , please use it to reproduce the issue :

https://www.dropbox.com/scl/fi/h7gptjv1bx31djtc94ftd/buraco.zip?rlkey=bgbpzv6lmp991ue2u5rrto7t8&dl=1

Steps: just create an android build and you will see the error.

I have used .NET 4.x
also added this line "AWSSDK.S3" in link file.
code stripping is false.
Still issue is happening.

Hi @santoshParihar,

Thanks for providing more information on this. Did you get a chance to try it out with the latest AWSSDK assemblies?

At a high level, when I see the project files that you shared, the AWSSDK assemblies inside Assets folder are outdated. I see those DLLs (Core, S3) are targeting .NET 3.5.

You may want to download the latest AWSSDK assemblies from here to use in your project.

Let me know the outcome once you obtain the latest assemblies for the AWS SDK for .NET.

Regards,
Chaitanya

This issue has not received a response in 5 days. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.