aws-sdk-net: AWS S3 SDK does not work on Unity 2019.1 Android

AWS S3 SDK does not work on Unity 2019.1

Expected Behavior

AWS S3 SDK works on Unity 2019.1

Current Behavior

After update to Unity 2019.1 AWS s3 sdk does not work. After call UnityInitializer.AttachToGameObject(this.gameObject); I see in logs exception:

04-17 22:51:29.910 4895-4917/? 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 
                                          a

Your Environment

  • AWSSDK.Core version used: AWSSDK.S3.3.3.101.4
  • Operating System and version: Android
  • Targeted .NET platform: 4.x

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 46 (9 by maintainers)

Most upvoted comments

Why was this issue closed when there are only hacky work arounds and no fix?

Sorry for a late response. I have just had the time to test the solution. By using this solution there is issues like

error CS0103: The name ‘UnityInitializer’ does not exist in the current context error CS0117: ‘AWSConfigs’ does not contain a definition for ‘HttpClient’ error CS0117: ‘AWSConfigs’ does not contain a definition for ‘HttpClientOption’

Also when will you be able to share some news for the Unity developers?

Using the provided .zip of netstandard2 .dlls did not prove any more fruitful than using the SDK as unity packages. I also spent a lot of time fiddling with downloading packages manually from nuget and extracting DLLs into my Unity project, only to find a ton of version discrepancies.

Ultimately, the only thing that worked was stealing the Assets/ dir .dlls from this kind hero’s example repo: https://github.com/rms80/awscognito-unity-accounts-demo

The fact that that folder is 2 years old and I still need it to operate in Unity (and I am using Unity 2020) says some attention needs to be paid to the Unity SDK. Ideally, there would be a unity AWS SDK for each major version of Unity, and a “latest” option for people trying to push the boundaries. Being that I am using a beta version of Unity, I expected to encounter some issues, but this really was quite a difficult operation even for an experienced developer.

Yes this is very difficult to set up for a noob like me. There were no clues that Unity Mobile SDK was deprecated until I happened on some forum posts looking for help. An up-to-date unity-centric tutorial provided by AWS would be really appreciated.

Hello, in case you decide to use the .NET Standard 2.0 version of the AWS SDK for .NET we have made available a download in .zip format that should be more convenient for Unity users (we also have version specific downloads using a URI like this one). We have also continued our testing and, whenever using IL2CPP, we recommend to add a file named link.xml in your project assets and configure it so that IL2CPP doesn’t strip any of the AWSSDK assemblies. It should look like this:

<linker>
       <assembly fullname="AWSSDK.Core" preserve="all"/>
       <assembly fullname="AWSSDK.DynamoDBv2" preserve="all"/>
       <assembly fullname="AWSSDK.Lambda" preserve="all"/>
</linker>

Please make sure to include all the AWSSDK dlls that you are using. The usage of link.xml is described here.

Solved by exporting my project as a unity package and importing it into a new project made in Unity 2018.3.14f1…after that you only have to write your tags again and delete the following files: androidx.browser.browser-1.0.0 androidx.browser.browser-1.0.0.aar androidx.core.core-1.0.0 androidx.core.core-1.0.0.aar from \YoureProjectLocation\Assets\Plugins\Android

@JakobJJ Make sure you reference the netstandard2.0 SDK assemblies and that you use the API reference at https://docs.aws.amazon.com/sdkfornet/v3/apidocs/Index.html. The nestandard2.0 assemblies don’t contain the UnityInitializer class and the AWSConfigs class doesn’t contain the HttpClient or HttpClientOptions properties. As you can see here, all of those are defined here in a unity-specific folder. If you are porting existing code using the Unity packages to the new netstandard2.0 assemblies, you will likely have to do some refactoring.

I am not able to comment on unannounced features but, if you have suggestions on what would make it easier to use the netstandard2.0 SDK in Unity, feel free to open an issue on this repo and tag me directly.

@Troshchuk @JakobJJ @asoule If you want a simpler way to get all the netstandard2.0 assemblies to use in your Unity project, you can use something like this PowerShell script. Obvioulsy you won’t need all downloaded assemblies, just AWSSDK.Core.dll and those for the services you use (like AWSSDK.S3.dll for example).

Amazon, can you either formally state that you no longer support Unity with the latest AWS SDK for .Net v3+ or provide a solution for the missing UnityInitializer? Or at least explicitly declare whether UnityInitializer is required anymore or not?

Hello?

Still a lot of views about this issue. You may watch this video to solve that step by step: https://youtu.be/uRNUJzQzNTk

Yes then i see… Thank you for clearing this up. I am porting a existing unity project that were using the old aws unitypackage. And that is why I’m getting all of these issues. I will open an issue and post some suggestions. Thank you @matteo-prosperi @JakobJJ I am also trying to port my existing project, were you able to do it? if so can you please explain how?

I removed net45 and paste nestandard2.0 and it works fine. @sstevenkang Thanks you very much. But I think you should simplify installing sdk for Unity users.

There are not any nestandard2.0 folders