在Android工作室中,AWS Rekognition检测标签错误

时间:2017-05-30 09:26:38

标签: amazon-web-services android-studio amazon-rekognition

当我实现这些代码时,会显示以下错误消息...

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)

0 个答案:

没有答案