I am trying to make one simple application in Xamrin android using Google Vision API.
What I did is,
Installed
- Google cloud vision v1,
- Google.Apis.Auth.OAuth2;
- Newtonsoft.Json;
in my xamarin.android project from NuGet manager.
I created
- API Key,
- Service Account,
- OAuth 2.0 client IDs
from google cloud console.
I created GOOGLE_APPLICATION_CREDENTIALS (Environmenta variable) and linked those Json file (both service account and OAuth 2.0 client IDs json) tried both.
Then I just copied code from google vision API documentaion.
// Load an image from a local file.
var image = Image.FromFile(filePath);
var client = ImageAnnotatorClient.Create();
var response = client.DetectLogos(image);
foreach (var annotation in response)
{
if (annotation.Description != null)
textView.Text = (annotation.Description);
}
everytime i try to compile the program it throws exception
System.InvalidOperationException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/ application-default-credentials for more information.
I need help to set default credentials, I tried many links from google documentation but no luck. has anyone got any idea how to handle this exception.