AWS面部识别试图用Android应用程序中的BasicAWSCredentials描述集合。]

满堂花醉三千客,一剑霜寒十四洲。这篇文章主要讲述AWS面部识别试图用Android应用程序中的BasicAWSCredentials描述集合。]相关的知识,希望能为你提供帮助。
[我正在尝试制作一个无需使用S3,Cognito或Amplify框架即可与AWS Facial Rekognition连接的android应用程序。我想在应用程序中对我的accessKey和secretKey进行硬编码。现在,我制作了一个非常简单的示例应用程序,因此我可以在Android Studio中测试Rekognition的功能(这是主要目的)。
当我按下按钮时,我正在调用“ DoIets”类的对象。但是我遇到了错误,并且没有发现任何错误。我允许在AndroidManifest.xml中进行互联网连接,并且具有accesKey和secretKey的用户具有AmazonRekognitionFullAccess策略。在gradle文件中,我导入了'com.amazonaws:aws-android-sdk-core:2.10。+'和'com.amazonaws:aws-android-sdk-rekognition:2.10.0'。
这是类“ DoeIets.java”

import android.util.Log; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.regions.Region; import com.amazonaws.regions.Regions; import com.amazonaws.services.rekognition.AmazonRekognition; import com.amazonaws.services.rekognition.AmazonRekognitionClient; import com.amazonaws.services.rekognition.model.DescribeCollectionRequest; import com.amazonaws.services.rekognition.model.DescribeCollectionResult; public class DoIets {public void main() { Log.w("Test", "In DoIets Class"); String collectionId = "MyCollectionName"; AWSCredentials credentials = new BasicAWSCredentials("MYACCESKEY", "MYSECRETKEY"); AmazonRekognition rekognitionClient = new AmazonRekognitionClient(credentials); rekognitionClient.setRegion(Region.getRegion(Regions.EU_CENTRAL_1)); DescribeCollectionRequest request = new DescribeCollectionRequest().withCollectionId(collectionId); DescribeCollectionResult describeCollectionResult = rekognitionClient.describeCollection(request); Log.w("Test", "Face count" + describeCollectionResult.getFaceCount()); } } 【AWS面部识别试图用Android应用程序中的BasicAWSCredentials描述集合。]】我得到的错误如下。

E/AndroidRuntime: FATAL EXCEPTION: main Process: be.example.testing, PID: 10174 java.lang.IllegalStateException: Could not execute method for android:onClick at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390) at android.view.View.performClick(View.java:7125) at android.view.View.performClickInternal(View.java:7102) at android.view.View.access$3500(View.java:801) at android.view.View$PerformClick.run(View.java:27336) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385) at android.view.View.performClick(View.java:7125) at android.view.View.performClickInternal(View.java:7102) at android.view.View.access$3500(View.java:801) at android.view.View$PerformClick.run(View.java:27336) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) Caused by: android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1565) at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:115) at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) at java.net.InetAddress.getAllByName(InetAddress.java:1152) at com.android.okhttp.Dns$1.lookup(Dns.java:41) at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:178) at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:144) at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:86) at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:176) at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128) at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97) at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289) at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131) at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:262) at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:219) at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:30) at com.amazonaws.http.UrlHttpClient.writeContentToConnection(UrlHttpClient.java:162) at com.amazonaws.http.UrlHttpClient.execute(UrlHttpClient.java:75) at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:371) at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:212) at com.amazonaws.services.rekognition.AmazonRekognitionClient.invoke(AmazonRekognitionClient.java:3006) at com.amazonaws.services.rekognition.AmazonRekognitionClient.describeCollection(AmazonRekognitionClient.java:762) at be.example.testing.DoIets.main(DoIets.java:25) at be.example.testing.MainActivity.doIets(MainActivity.java:25) at java.lang.reflect.Method.invoke(Native Method) at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385) at android.view.View.performClick(View.java:7125) at android.view.View.performClickInternal(View.java:7102) at android.view.View.access$3500(View.java:801) at android.view.View$PerformClick.run(View.java:27336) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) I/Process: Sending signal. PID: 10174 SIG: 9

[我正在尝试制作一个无需使用S3,Cognito或Amplify框架即可与AWS Facial Rekognition连接的Android应用程序。我想在...

    推荐阅读