- I have a problem when use Cloud Google Vision API reading a picture information.
- I receive the following error:
Cloud Vision API reuqest failed.Check logs for details.
After debugging, I notice the code runs to the line:
BatchAnnotateImagesResponse response = annotateRequest.execute();then runs to linereturn "Cloud Vision API request failed. Check logs for details.";protected String doInBackground(Object... params) { try{HttpTransport httpTransport = AndroidHttp.newCompatibleTransport(); JsonFactory jsonFactory = GsonFactory.getDefaultInstance(); VisionRequestInitializer requestInitializer = new VisionRequestInitializer(CLOUD_VISION_API_KEY); Vision.Builder builder = new Vision.Builder(httpTransport, jsonFactory, null); builder.setVisionRequestInitializer(requestInitializer); Vision vision = builder.build(); BatchAnnotateImagesRequest batchAnnotateImagesRequest = new BatchAnnotateImagesRequest(); batchAnnotateImagesRequest.setRequests(annotateImageRequests); Vision.Images.Annotate annotateRequest = vision.images().annotate(batchAnnotateImagesRequest); annotateRequest.setDisableGZipContent(true); BatchAnnotateImagesResponse response = annotateRequest.execute(); return convertResponseToString(response); } catch (GoogleJsonResponseException e) { Log.d(TAG, "failed to make API request because " + e.getContent()); } catch (IOException e) { Log.d(TAG, "failed to make API request because of other IOException " + e.getMessage()); } return "Cloud Vision API request failed. Check logs for details."; }Currently I use version
minSdkVersion 21andtargetSdkVersion 26- Android 3.2.1
- I don't activate free trial google api.
- Link code github you can downnload and test:
- Who can help me with this issue?
Comments
Post a Comment