我正在使用适用于Android的AWS cognito SDK 2.4.3版。它在调试版本上工作得很好,但是在发行版上,如果出现错误,我将无法获得有关异常的正确描述。相反,我得到这个

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) 

在调试版本上,我得到一个异常,详细说明了错误。但是,如果所有字段都写得很好,则在发行版和调试版中,用户注册都会成功。我在发布时使用了proguard,并且遵循了this file的规则

任何有关此问题的帮助将不胜感激。

最佳答案

在尝试了不同的Proguard设置之后,以下是用于使它正常工作的最小配置,是对AWS SDK存储库所建议的最小配置

-keep class com.amazonaws.services.cognitoidentityprovider.** { *; }

必须将其添加到app/proguard-rules.pro

关于Android和AWS Cognito-无法使用Proguard解码错误响应,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44207343/

10-12 04:04
查看更多