Android Amplify Authentication with AWSMobileClient crashes at User Sign Up


I want to implement a simple signIn/SignUp Functionality in my android app using AWS Cognito and AWS Amplify Authentication.
To make it more easy, I want to use the SignInUI from the AWSMobileClient class.
The UI gets shown with the signIn screen. After selecting the "Sign Up as new user" option I get a signUp screen and I can sign up as a new user. After entering my email and password and clicking "sign up", the new user gets created in my cognito user pool in my AWS console. I also receive the registration code via email. So far so good, but the app crashes with this message:

2020-12-07 19:46:42.250 8018-8018/de.stuttgart.myAppName E/AndroidRuntime: FATAL EXCEPTION: main
Process: de.stuttgart.myAppName , PID: 8018
java.lang.AbstractMethodError: abstract method "void com.amazonaws.mobileconnectors.cognitoidentityprovider.handlers.SignUpHandler.onSuccess(com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUser,"
at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool$1$
at android.os.Handler.handleCallback(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invoke(Native Method)

The crash seems to happen in the signUpInBackground() -> onSuccess() method in the class, I think AWSMobileClient may doesn't know what to do after a successfull singUp. I would like it to show the signIn screen again, so that the signedUp User now can signIn. How do I do that?

When I restart the app, the SignIn screen gets shown again and I can login with this user (after entering the registration code that was sent to my email) and I get redirected to my next Activity (SelectTopCategoryActivity.class) in my App and the user gets confirmed in AWS Cognito. So this works fine.

But why does it crash on SignUp?

I initailize the AWSMobileClient like this in my AuthenticationActivity's "onCreate" method:

AWSMobileClient.getInstance().initialize(getApplicationContext(), new Callback<UserStateDetails>() {

        public void onResult(UserStateDetails userStateDetails) {  
            Log.i(TAG, userStateDetails.getUserState().toString());  
            switch (userStateDetails.getUserState()){  
                case SIGNED_IN:  
                    Log.d(TAG, "onResult: Login successful");  
                    Intent i = new Intent(AuthenticationActivity.this, SelectTopCategoryActivity.class);  
                case SIGNED_OUT:  

        public void onError(Exception e) {  
            Log.d(TAG, "onError: error");  
            Log.e(TAG, e.toString());  

When the user is not logged in the showSignIn() gets called:

private void showSignIn() {
try {
} catch (Exception e) {
Log.d(TAG, "showSignIn: failed");
Log.e(TAG, e.toString());

my manifest:

<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- <activity android:name=".SwipeActivity">--> <!-- <intent-filter>--> <!-- <action android:name="android.intent.action.MAIN" />--> <!-- <category android:name="android.intent.category.LAUNCHER" />--> <!-- </intent-filter>--> <!-- </activity>-->
    <activity android:name=".AuthenticationActivity">  
            <action android:name="android.intent.action.MAIN" />  

            <category android:name="android.intent.category.LAUNCHER" />  
    <activity android:name=".RecipeActivity" />  
    <activity android:name=".SelectTopCategoryActivity" />  
    <activity android:name=".RecipeListActivity" />  
    <activity android:name=".CircleListActivity" />  
    <activity android:name=".SwipeActivity" />  

my build.gradle imports:

dependencies {
def retrofitVersion = "2.9.0"
def lifecycle_version = "1.1.1"
def cardview_version = "1.0.0"
def recyclerView_version = "1.0.0"
def glideVersion = "4.11.0"
def supportVersion = "28.0.0"
def aws_version = "2.13.+"

implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'  
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'  

implementation 'androidx.appcompat:appcompat:1.2.0'  
implementation ''  

// implementation ''

testImplementation 'junit:junit:4.+'  
androidTestImplementation 'androidx.test.ext:junit:1.1.2'  
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'  

implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"  
// Retrofit gson converter  
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"  

// ViewModel and LiveData  
implementation "android.arch.lifecycle:extensions:$lifecycle_version"  

// CardViews  
implementation "androidx.cardview:cardview:$cardview_version"  

// RecyclerView  
implementation "androidx.recyclerview:recyclerview:$recyclerView_version"  

//Design library  

implementation "$supportVersion"

// Glide  
implementation 'com.github.bumptech.glide:glide:4.8.0'  
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'  

// Circular ImageView  
implementation 'de.hdodenhof:circleimageview:3.1.0'  

// Google Tabs  
implementation "androidx.browser:browser:1.2.0"  

// SwipeCards  
implementation 'com.lorentzos.swipecards:library:1.0.9'  

// Amplify core dependency (for AWS Cognito)  
implementation 'com.amplifyframework:core:1.6.4'  
implementation 'com.amplifyframework:aws-auth-cognito:1.6.4'  

// AWS Dependencies  

implementation "com.amazonaws:aws-android-sdk-core:$aws_version"  
implementation "com.amazonaws:aws-android-sdk-auth-core:$aws_version"  
implementation("com.amazonaws:aws-android-sdk-auth-userpools:$aws_version@aar") { transitive = true }  
implementation("com.amazonaws:aws-android-sdk-auth-ui:$aws_version") { transitive = true }  

// Support for Java 8 features  
coreLibraryDesugaring ''  

implementation ''  
implementation ''  

// Mobile Client for initializing the SDK  
implementation ('com.amazonaws:aws-android-sdk-mobile-client:2.6.+@aar') { transitive = true; }  

// Cognito UserPools for SignIn  
implementation ''  
implementation ('com.amazonaws:aws-android-sdk-auth-userpools:2.6.+@aar') { transitive = true; }  

// Sign in UI Library  
implementation ''  
implementation ('com.amazonaws:aws-android-sdk-auth-ui:2.6.+@aar') { transitive = true; }  


These are the settings of the cognito user pool, which is referenced in my amplifyconfiguration.json:

'>amplify update auth
Please note that certain attributes may not be overwritten if you choose to use defaults settings.
Using service: Cognito, provided by: awscloudformation
What do you want to do? Walkthrough all the auth configurations
Select the authentication/authorization services that you want to use: User Sign-Up & Sign-In only (Best used with a cloud API only)
Do you want to add User Pool Groups? No
Do you want to add an admin queries API? No
Multifactor authentication (MFA) user login options: OFF
Email based user registration/forgot password: Enabled (Requires per-user email entry at registration)
Please specify an email verification subject: Your verification code
Please specify an email verification message: Your verification code is {####}
Do you want to override the default password policy for this User Pool? Yes
Enter the minimum password length for this User Pool: 6
Select the password character requirements for your userpool:
Specify the app's refresh token expiration period (in days): 30
Do you want to specify the user attributes this app can read and write? No
Do you want to enable any of the following capabilities?
Do you want to use an OAuth flow? No
Warning! Your existing IdentityPool: syzl8795f11f_identitypool_8795f11f will be deleted upon the next “amplify push”!
? Do you want to configure Lambda Triggers for Cognito? No
Successfully updated auth resource syzl8795f11f locally

'>amplify push

Edited by: Grg on Dec 7, 2020 11:16 AM

Edited by: Grg on Dec 7, 2020 11:19 AM

Edited by: Grg on Dec 7, 2020 11:29 AM

Edited by: Grg on Dec 7, 2020 11:33 AM

asked 2 years ago170 views
1 Answer

Hi @Grg, version 1.6.4 of the Amplify framework depends on 2.19.3_ ( of the AWS SDK. Your build.gradle depends on 2.13._ of the AWS SDK, which is not compatible with your version of Amplify (1.6.4), and is likely the reason why you are seeing this crash.

You should not need to depend on the AWS SDK at all, unless you actually need to use AWSMobileClient directly. The recommended approach for new apps though is to just use Amplify, which sits on top of AWSMobileClient. Here is the documentation for signIn with Amplify:

If you do still need to use AWSMobileClient directly, make sure to use the latest version so it is compatible with Amplify, which is 2.19.3.

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions