Summary
When binding a JAR/AAR built on top of aws-java-sdk, do you have to EmbeddedReferenceJar 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.
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 ?
Context
I would like to use SignInUI from aws-android-sdk-auth-ui
in a Xamarin.Android app, which gives you an out-of-the-box UI for authentication to AWS. I've got the AWS UserPool
and AWS IdentityPool
setup already.
Unfortunately, the AWS SDK for .NET
does not expose the equivalent aws-android-sdk-auth-ui
a java package built on top of aws-android-sdk-auth-core
(also unavailable in .NET), which is built on top of aws-android-sdk-core
and finally aws-java-sdk
.
I thought about binding a java library. I would create a Xamarin binding project for aws-android-sdk-auth-ui.aar
downloaded from maven Central. I followed the Binding an .AAR tutorial. It builds, but the generated aws-android-sdk-auth-ui.dll
file is missing some classes. I opened the dll with Ildasm.exe
and in the Com.Amazonaws.Mobile.Auth.UI
namespace I only found AuthUIConfiguration
and BuildConfig
, clearly missing the SignInUI
class.
Is it expected that when you build a binding project for an .aar
file that references other .jar
, 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.
Alright, so I added aws-android-sdk-auth-core.jar
, aws-android-sdk-core.jar
to the bindings project, as EmbeddedReferencedJar. That did not help, the generated dll
is also missing the same classes. The build output pasted below does point in the direction of misssing reference jars. See below.
How far do I need to go though, do I also need to embed all the way down to the 80MB aws-java-sdk.jar
?
I have the following build output:
1>JARTOXML : warning J2X9001: Couldn't load class com/amazonaws/mobile/auth/ui/SignInActivity : java.lang.NoClassDefFoundError: android/support/v7/app/AppCompatActivity
1>JARTOXML : warning J2X9001: Couldn't load class com/amazonaws/mobile/auth/ui/SignInUI$1 : java.lang.NoClassDefFoundError: com/amazonaws/mobile/auth/core/DefaultSignInResultHandler
1>JARTOXML : warning J2X9001: Couldn't load class com/amazonaws/mobile/auth/ui/SignInActivity$SignInProviderResultHandlerImpl : java.lang.NoClassDefFoundError: com/amazonaws/mobile/auth/core/signin/SignInProviderResultHandler
android/support/v7/app/AppCompatActivity
indicates thatcom.android.support:appcompat
isn't found. How are those supposed to bind? In Xamarin.Android these classes are inXamarin.Android.Support.v7.AppCompat
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...com/amazonaws/mobile/auth/core/DefaultSignInResultHandler
: that one should not error, I did embed aws-android-sdk-auth-core.jar with EmbbededRefenceJar
Update:
Someone referred me to Xamarin.GradleBindings. I haven't tested this yet, but thought I'd share in hopes this can be useful to other readers.