当我实现这些代码时显示以下错误消息...
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext.getApplicationContext(),
"us-west-2:...",// Identity Pool ID
Regions.US_WEST_2 // Region
);
AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient(credentialsProvider); <--Error Here
DetectLabelsRequest request = new DetectLabelsRequest()
.withImage(new Image()
.withBytes(imageBytes))
.withMaxLabels(10)
.withMinConfidence(77F);
控制台消息:AmazonWebServiceClient:在区域元数据中找不到 {cognito-identity,us-west-2},尝试使用该区域的标准模式构造端点:'cognito-identity.us-west-2.amazonaws.com '。
CognitoCachingCredentialsProvider:从 SharedPreferences 加载凭据 CognitoCachingCredentialsProvider:在 SharedPreferences 中找不到有效凭据
错误信息:
java.lang.NoSuchMethodError: No static method isInRegionOptimizedModeEnabled()Z in class Lcom/amazonaws/SDKGlobalConfiguration; or its super classes (declaration of 'com.amazonaws.SDKGlobalConfiguration' appears in /data/app/com.example.name.app-1/base.apk:classes11.dex)
at com.amazonaws.ClientConfigurationFactory.getConfig(ClientConfigurationFactory.java:35)
at com.amazonaws.services.rekognition.AmazonRekognitionClient.<init>(AmazonRekognitionClient.java:210)
at com.example.name.app.DetectLabelsExampleImageBytes.main(DetectLabelsExampleImageBytes.java:67)
at com.example.name.app.PhotoActivity.detectHash(PhotoActivity.java:186)
at com.example.name.app.PhotoActivity.onActivityResult(PhotoActivity.java:158)
at android.app.Activity.dispatchActivityResult(Activity.java:6470)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3716)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3763)
at android.app.ActivityThread.-wrap16(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1403)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)