I am using the AWS cognito SDK for Android, version 2.4.3. It works perfectly fine on debug version, but on release versions, in case of error, I cannot get a proper description on the exception. Instead, I get this
com.amazonaws.AmazonClientException: Unable to unmarshall error response (<init> [class java.lang.String]). Response Code: 400, Response Text: Bad Request
at com.amazonaws.http.AmazonHttpClient.a(Unknown Source)
at com.amazonaws.http.AmazonHttpClient.b(Unknown Source)
at com.amazonaws.http.AmazonHttpClient.a(Unknown Source)
at com.amazonaws.services.cognitoidentityprovider.AmazonCognitoIdentityProviderClient.a(Unknown Source)
at com.amazonaws.services.cognitoidentityprovider.AmazonCognitoIdentityProviderClient.a(Unknown Source)
at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool.a(Unknown Source)
at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool.a(Unknown Source)
at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NoSuchMethodException: <init> [class java.lang.String]
at java.lang.Class.getConstructor(Class.java:531)
at java.lang.Class.getConstructor(Class.java:495)
at com.amazonaws.transform.AbstractErrorUnmarshaller.a(Unknown Source)
at com.amazonaws.transform.JsonErrorUnmarshaller.b(Unknown Source)
at com.amazonaws.services.cognitoidentityprovider.model.transform.InvalidParameterExceptionUnmarshaller.b(Unknown Source)
at com.amazonaws.http.JsonErrorResponseHandler.a(Unknown Source)
at com.amazonaws.http.JsonErrorResponseHandler.b(Unknown Source)
at com.amazonaws.http.JsonErrorResponseHandler.a(Unknown Source)
at com.amazonaws.http.AmazonHttpClient.a(Unknown Source)
at com.amazonaws.http.AmazonHttpClient.b(Unknown Source)
at com.amazonaws.http.AmazonHttpClient.a(Unknown Source)
at com.amazonaws.services.cognitoidentityprovider.AmazonCognitoIdentityProviderClient.a(Unknown Source)
at com.amazonaws.services.cognitoidentityprovider.AmazonCognitoIdentityProviderClient.a(Unknown Source)
at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool.a(Unknown Source)
at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool.a(Unknown Source)
at com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:818)
On debug version I get an exception indicating in detail the error. However, in both release and debug user registration succeeds in case all fields are well written. I am using proguard on release and I am aplying the rules from this file
Any help with this issue will be appreciated.
After trying different Proguard settings, following is the minimal configuration, additional to that suggested on AWS SDK repository, to make it work
-keep class com.amazonaws.services.cognitoidentityprovider.** { *; }
it must be added to app/proguard-rules.pro
Unmarshalling errors can also occur with classes in the AWS core library, not just com.amazonaws.services.cognitoidentityprovider
. This rule will prevent this crash for all AWS lib exceptions:
-keep class * extends com.amazonaws.AmazonClientException { *; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With