Front-End Web & Mobile

AWS Amplify Library Announces v2.0 Amplify Library for Android

Today, we are excited to announce the general availability of v2.0 Amplify Library for Android!

Amplify Library for Android allows developers building apps for the Android platform to easily include features like authentication, storage, maps, and more. The latest major version of this library has been re-written to improve Android developers experience and is now built on top of the AWS SDK for Kotlin. As with the Preview, the Amplify Library for Android is open source on GitHub, and we deeply appreciate the feedback we have gotten from the community.

Highlights

With the v2.0 of Amplify Library for Android, we have added new features and made many improvements to the Android developer experience. the following are some of the highlights included as part of this major version release.

Authentication

  • All Authentication features like federated sign-in are available directly from the Amplify Library without needing to access the underlying AWSMobileClient from the AWS SDK for Android.
  • Federated Auth Flows can now be integrated with Cognito’s Identity Pool. This means that developers can now use 3rd party federated tokens with Cognito’s Identity pool to get AWS credentials. This was previously only available via the escape hatch in v1 and is now natively available from Amplify’s Authentication APIs.
(Amplify.Auth.getPlugin("awsCognitoAuthPlugin") as? AWSCognitoAuthPlugin)?.let { plugin ->
    plugin.federateToIdentityPool(
        "YOUR_TOKEN",
        AuthProvider.facebook(),
        {
            Log.i("AuthQuickstart", "Successful federation to Identity Pool.")
            // use "it.credentials"
        },
        {
            Log.e("AuthQuickstart", "Failed to federate to Identity Pool.", it)
        }
    )
}
  • Sign-out workflows now offer more visibility into error handling so you can manually retry failed sign-out steps when needed. Please refer to the sign-out documentation for more details on how you can handle different error states.
  • The new forceRefresh() feature can now be passed in as an option to the fetchAuthSession() API, which allows developers to proactively refresh the session token of a signed in user. This saves users from having to sign back in to the app when their user scope has been modified.
val options = AuthFetchSessionOptions.builder().forceRefresh(true).build()

Storage

  • All Storage features previously accessed via TransferUtility are now available in the latest version of Storage library in the Amplify Library for Android.
  • The GetTransfer() API allows developers to query active transfers. This allows developers regain control of ongoing transfer operations across app sessions.
  • Amplify storage now uses Android Jetpack WorkManager eliminating the need to show the foreground transfer notifications which were non-dismissible.

Escape Hatch

With the Amplify Library for Android, you have direct access to the underlying AWS SDK for Kotlin through the escape hatch to unlock additional capabilities from AWS services.

You can follow our Upgrade Guide here to access AWS SDK for Kotlin features from the Amplify Library for Android.

Conclusion

You can start using this latest version of the Amplify Library for Android by following the documentation here.

We would love to have your feedback on this release and understand how we can help accelerate your productivity. Reach out to us our GitHub repository, or through the Amplify Discord server under the #android-help channel to help us prioritize features and enhancements.