Android 和 AWS Cognito - 无法使用混淆器解组错误响应
Android and AWS Cognito - Unable to unmarshall error response with proguard
我正在使用 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.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.run(Unknown Source)
at java.lang.Thread.run(Thread.java:818)
在调试版本中,我收到一个异常,详细说明了错误。但是,如果所有字段都写得很好,则在发布和调试中用户注册都会成功。我在发布时使用了混淆器,我正在应用 this file
中的规则
任何对此问题的帮助将不胜感激。
在尝试不同的 Proguard 设置后,除了 AWS SDK 存储库中建议的配置之外,以下是最小配置,以使其正常工作
-keep class com.amazonaws.services.cognitoidentityprovider.** { *; }
必须添加到 app/proguard-rules.pro
AWS 核心库中的 类 也可能出现解组错误,而不仅仅是 com.amazonaws.services.cognitoidentityprovider
。此规则将防止所有 AWS 库异常崩溃:
-keep class * extends com.amazonaws.AmazonClientException { *; }
我正在使用 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.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.run(Unknown Source)
at java.lang.Thread.run(Thread.java:818)
在调试版本中,我收到一个异常,详细说明了错误。但是,如果所有字段都写得很好,则在发布和调试中用户注册都会成功。我在发布时使用了混淆器,我正在应用 this file
中的规则任何对此问题的帮助将不胜感激。
在尝试不同的 Proguard 设置后,除了 AWS SDK 存储库中建议的配置之外,以下是最小配置,以使其正常工作
-keep class com.amazonaws.services.cognitoidentityprovider.** { *; }
必须添加到 app/proguard-rules.pro
AWS 核心库中的 类 也可能出现解组错误,而不仅仅是 com.amazonaws.services.cognitoidentityprovider
。此规则将防止所有 AWS 库异常崩溃:
-keep class * extends com.amazonaws.AmazonClientException { *; }