Skip to content
This repository was archived by the owner on Aug 3, 2026. It is now read-only.
This repository was archived by the owner on Aug 3, 2026. It is now read-only.

DetectModerationLabels Rekognition - No Direct Equivalent in Amplify Android v2 #3691

Closed

Description

@hvar90

I am currently migrating from the AWS Mobile SDK for Android to Amplify Android v2. A key feature of my app is content moderation using DetectModerationLabels through Amazon Rekognition. In the legacy AWS Mobile SDK, this functionality was available via the AWSRekognitionClient.

However, in the new Amplify Android v2 SDK, there is no direct equivalent for this feature. The only mention I've found is in the Gen 1 documentation, where an "escape hatch" through AWSPredictionsPlugin.getEscapeHatch().getRekognitionClient() is provided for accessing the Rekognition client directly (see Use AWS SDK - Android - AWS Amplify Gen 1 Documentation).

My question is: What is the recommended approach to using DetectModerationLabels with Amplify Android v2? Is there a new API or category that replaces this? Has it been intentionally left out, or is there a plan to include it in future releases?

Thank you for your guidance.

Activity

  1. thisisabhash commented on May 14, 2026

    @thisisabhash
    Member

    Hello,
    Thank you for posting this issue.

    Currently, Amplify Android v2 supports these features: https://docs.amplify.aws/gen1/android/build-a-backend/more-features/predictions/

    For functionality not supported through AWSPredictionsPlugin, using the getEscapeHatch() to get the RekognitionClient directly is the recommended approach.

  2. added
    questionGeneral question
    and removed on May 14, 2026
  3. hvar90 commented on May 15, 2026

    @hvar90
    Author

    Thank you for the clarification regarding Gen 1.

    Could you please guide me on how to achieve this same content moderation functionality using Amplify Gen 2?

    Specifically, would the exact same Android client code that I use to call DetectModerationLabels in Gen 1 still work for a Gen 2 project, or does this implementation change completely under the new Gen 2?

    Also, should I continue using the same dependency,
    implementation 'com.amplifyframework:aws-predictions:2.36.0',
    or is there a different dependency/approach required for Gen 2?

    I am asking because when I use my current configuration with the Gen 2 amplify_outputs.json:

    
    Amplify.addPlugin(new AWSCognitoAuthPlugin());
    Amplify.addPlugin(new AWSPredictionsPlugin());
    Amplify.addPlugin(new AWSS3StoragePlugin());  
    
    AmplifyOutputs outputs = AmplifyOutputs.fromResource(R.raw.amplify_outputs);
    Amplify.configure(outputs, getApplicationContext());
    
    

    Authentication and Storage work perfectly fine, but initialization crashes on the Predictions plugin with this exact error:

    textPredictionsException{message=AWSPredictionsPlugin is not supported when using Amplify Gen2, cause=null, recoverySuggestion=This plugin is not supported by Amplify Gen2. Remove this plugin to use Gen2.}

    Given this explicit error stating that the plugin is not supported in Gen 2, what is the recommended way to perform content moderation from an Android app using Gen 2?

    considering the official warning on the Gen 1 documentation stating:"Amplify Gen 1 has entered maintenance mode and will reach end of life on May 1, 2027. New projects should use Amplify Gen 2" between now and May 2027, is there a plan to release a new version or alternative dependency (similar to com.amplifyframework:aws-predictions) that fully supports Gen 2 ?

  4. mattcreaser commented on May 22, 2026

    @mattcreaser
    Member

    Hi @hvar90, you probably just don't need to use Amplify for your use case. The PredictionsPlugin is simply a pass through to the Kotlin SDK's RekognitionClient, so you should be able to use that directly.

    You can still use Amplify v2 Auth to provide credentials for the RekognitionClient using the following. This is what the Predictions Plugin is doing internally.

    val client = RekognitionClient {
        region = "us-east-1" // or whatever your region is
        credentialsProvider = CognitoCredentialsProvider() // uses Amplify.Auth to provide credentials for making requests
    }
    
    // make a request
    val result = client.detectModerationLabels {
         image = { ... }
    }

    Hope that helps!

  5. hvar90 commented on May 24, 2026

    @hvar90
    Author

    Hi @mattcreaser ,

    Thank you for the workaround! It clarifies a lot.

    Since my Android app is fully written in Java, I would appreciate your advice on the best library choice for this approach.

    Which one do you recommend for a Java-based Android project?

    software.amazon.awssdk:rekognition (AWS SDK for Java v2)
    aws.sdk.kotlin:rekognition (AWS SDK for Kotlin)

    If I should go with the Kotlin SDK as you snippet suggests, what is the best way to call it from Java code while maintaining compatibility with CognitoCredentialsProvider()?
    On the other hand, if I use the Java v2 SDK, is there an equivalent way to easily bridge Amplify v2 Auth credentials into it?

    Thank you again for your guidance!

  6. jvh-aws commented on May 28, 2026

    @jvh-aws
    Contributor

    @hvar90, I'd using the Kotlin SDK (aws.sdk.kotlin:rekognition), which should work best for Android

    Even in a Java project, you can call it via a small Kotlin helper. E.g.:

    // RekognitionHelper.kt
    object RekognitionHelper {
        @JvmStatic
        fun detectModerationLabels(...) = runBlocking {
            RekognitionClient {
                this.region = region
                credentialsProvider = CognitoCredentialsProvider()
            }.use { it.detectModerationLabels { ... } } }
        }
    }

    Then from Java:

    var result = RekognitionHelper.detectModerationLabels(imageBytes, "us-east-1");

    CognitoCredentialsProvider() bridges your Amplify Auth credentials automatically.

  7. hvar90 commented on May 28, 2026

    @hvar90
    Author

    Hi @jvh-aws ,Just wanted to thank you for the recommendation! Moving to the AWS Kotlin SDK totally fixed my issues on older Android versions. Appreciate the help! Everything is working perfectly now, so I'll close this case.

  8. github-actions commented on May 28, 2026

    @github-actions
    Contributor

    This issue is now closed. Comments on closed issues are hard for our team to see.
    If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending-maintainer-responseIssue is pending response from an Amplify team memberquestionGeneral questionrekognitionIssues with the AWS Android SDK for Rekognition.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions