I am developing an android application which requires use of google vision service provided by Google Cloud Platform. For authentication, this uses a class GoogleCredential class, the code for which can be found here:
https://cloud.google.com/vision/docs/label-tutorial#authenticating
I need to set GOOGLE_APPLICATION_CREDENTIALS variable as an environment variable pointing to a json file downloaded from another link, which is not important.
The question is: When I set the environment variable using
Uri otherPath = Uri.parse("android.resource://com.example.himanshu.myapplication/DtnPhotoShare-ff552ae2c96c.json");
System.setProperty("**GOOGLE_APPLICATION_CREDENTIALS**",otherPath.toString());
It gives me exception :
java.io.IOException: The Application Default Credentials are not available. They are available if running on Google App Engine, Google Compute Engine, or Google Cloud Shell. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials.
in line
GoogleCredential credential =
GoogleCredential.getApplicationDefault().createScoped(VisionScopes.all());
All the code can be found in the link given above.