title: Xamarin binding for AWS SDK
body: <p><strong>Summary</strong></p>
  
  <ul>
  <li><p>When binding a JAR/AAR built on top of aws-java-sdk, do you have to <strong>EmbeddedReferenceJar</strong> all the libraries below your JAR, down to and including the aws-java-sdk, when down at that low level the AWS SDK for .NET has the functionality.</p></li>
  <li><p>Are there any Xamarin packages (Xamarin.Forms or Xamarin.Android) that give an out-of-the box authentication UI with Sign-In/Sign-Up buttons for AWS user pools, Google+, Facebook authentication providers ?</p></li>
  </ul>
  
  <p><strong>Context</strong></p>
  
  <p>I would like to use SignInUI from <code>aws-android-sdk-auth-ui</code> in a Xamarin.Android app, which gives you an out-of-the-box UI for authentication to AWS. I've got the <code>AWS UserPool</code> and <code>AWS IdentityPool</code> setup already.</p>
  
  <p>Unfortunately, the <code>AWS SDK for .NET</code> does not expose the equivalent <code>aws-android-sdk-auth-ui</code> a java package built on top of <code>aws-android-sdk-auth-core</code> (also unavailable in .NET), which is built on top of <code>aws-android-sdk-core</code> and finally <code>aws-java-sdk</code>.</p>
  
  <p>I thought about binding a java library. I would create a Xamarin binding project for <code>aws-android-sdk-auth-ui.aar</code> downloaded from maven Central. I followed the <a href="https://docs.microsoft.com/en-us/xamarin/android/platform/binding-java-library/binding-an-aar" rel="nofollow noreferrer">Binding an .AAR</a> tutorial. It builds, but the generated <code>aws-android-sdk-auth-ui.dll</code> file is missing some classes. I opened the dll with <code>Ildasm.exe</code> and in the <code>Com.Amazonaws.Mobile.Auth.UI</code> namespace I only found <code>AuthUIConfiguration</code> and <code>BuildConfig</code>, clearly missing the <code>SignInUI</code> class.</p>
  
  <p>Is it expected that when you build a binding project for an <code>.aar</code> file that references other <code>.jar</code>, the build succeeds but silently does not produce wrapper classes for java classes who reference missing jars? I would have guessed building would succeed AND would include a wrapper for all classes, but a failure would occur at runtime in codepaths that require the missing jar.</p>
  
  <p>Alright, so I added <code>aws-android-sdk-auth-core.jar</code>, <code>aws-android-sdk-core.jar</code> to the bindings project, as <strong>EmbeddedReferencedJar</strong>. That did not help, the generated <code>dll</code> is also missing the same classes. The build output pasted below does point in the direction of misssing reference jars. See below.</p>
  
  <p>How far do I need to go though, do I also need to embed all the way down to the 80MB <code>aws-java-sdk.jar</code>?</p>
  
  <p>I have the following build output:</p>
  
  <pre><code>1&gt;JARTOXML : warning J2X9001: Couldn't load class com/amazonaws/mobile/auth/ui/SignInActivity : java.lang.NoClassDefFoundError: android/support/v7/app/AppCompatActivity
  1&gt;JARTOXML : warning J2X9001: Couldn't load class com/amazonaws/mobile/auth/ui/SignInUI$1 : java.lang.NoClassDefFoundError: com/amazonaws/mobile/auth/core/DefaultSignInResultHandler
  1&gt;JARTOXML : warning J2X9001: Couldn't load class com/amazonaws/mobile/auth/ui/SignInActivity$SignInProviderResultHandlerImpl : java.lang.NoClassDefFoundError: com/amazonaws/mobile/auth/core/signin/SignInProviderResultHandler
  </code></pre>
  
  <ul>
  <li><code>android/support/v7/app/AppCompatActivity</code> indicates that <code>com.android.support:appcompat</code> isn't found. How are those supposed to bind? In Xamarin.Android these classes are in
  <code>Xamarin.Android.Support.v7.AppCompat</code> Nuget package. But the jar does not know it's running in Xamarin.Android. Does that mean I also need to EmbedReferenceJar all the native Android stuff as well? That's a deep rabbit hole...</li>
  <li><code>com/amazonaws/mobile/auth/core/DefaultSignInResultHandler</code>: that one should not error, I did embed aws-android-sdk-auth-core.jar with <strong>EmbbededRefenceJar</strong></li>
  </ul>
  
  <p><strong>Update:</strong></p>
  
  <p>Someone referred me to <a href="https://marketplace.visualstudio.com/items?itemName=EgorBogatov.XamarinGradleBindings" rel="nofollow noreferrer">Xamarin.GradleBindings</a>. I haven't tested this yet, but thought I'd share in hopes this can be useful to other readers.</p>