I am trying to use Google Cloud Speech recognition but I get this error
I/omputeEngineCredentials: Failed to detect whether we are running on
Google Compute Engine. W/System.err: java.io.IOException: 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 set the environment variable from System Properties/Environment Variables/User variables and also I set the credentials manually using this guide.
I have searched every topic that is relevant to this, but I can't get it to work. What am I missing?
I faced this issue while connecting to Cloud Storage from local .Following are the steps I followed that worked for me:
Install Cloud SDK. Reference link:Cloud SDK
Follow all the steps to initialize the SDK.
Now ,create application default credentials by using the following command in the root directory of your application gcloud auth application-default login, by which google-cloud will automatically detect your credentials.
It is hard to say without access to logs and code, but probably you should start from debugging accesses to speech API from console directly.
gcloud auth activate-service-account --key-file=[PATH]
gcloud ml speech recognize 'gs://cloud-samples-tests/speech/brooklyn.flac' \ --language-code='en-US'
https://cloud.google.com/blog/products/ai-machine-learning/ml-explorer-talking-and-listening-with-google-cloud-using-cloud-speech-and-text-to-speech
Possible reasons are:
- API is disabled,
- credential you use doesn't contains permissions for ML.
- credential file path is wrong.
Related
Before a few days i got mail.
Enable the Cloud Build API for your projects before April 20, 2020, to
ensure Cloud Function is built and deployed correctly.
Access the Cloud Build API link in the Cloud Console.
Select your project from the drop-down menu.
Click Continue to enable the Cloud Build API for the project. A box will appear in the lower-left corner to confirm the API is enabled.
After click i getting following error for some permission
This API cannot be enabled at the moment. You may lack appropriate permissions.
.
So, which type of permission required i need to enable this service ?
The specific permissions that a user needs to enable APIs for a GCP project are:
serviceusage.services.enable
servicemanagement.services.bind
If you are already the owner of your project, you shouldn't have to add the roles/servicemanagement.serviceConsumer role to your account to enable an API.
You also need to enable billing on the project before you can enable new APIs.
The error I was getting
This API cannot be enabled at the moment. You may lack appropriate
permissions.
The issue for me was I have multiple google / gmail accounts and when I changed deploy location I had to logout and then log back in:
firebase logout
and then log back in
firebase login
This was followed by opening browser and then selecting the appropriate google user to deploy application with.
We were using a GCP API key on multiple platforms (Android, iOS, Web) for Google map, Location search (api/place/autocomplete), static Google Map, etc.
Now I wanted to create a new/separate Key for Android App so I can add appropriate restrictions like package name SHA1 and used APIs.
I've created a new key, Changed it into the App after that map is working fine but Location search API is kept throwing an exception-
This IP, site or mobile application is not authorized to use this API key. Request received from IP address <ip>, with empty referer",
Has anyone faced this issue? Or any clue that how should I debug this?
You cannot make web service requests using an API key that is Android or iOS restricted. Web services are server-side and only work with API keys that are restricted by IP address.
Each of your API keys should be restricted properly based on the API in use.
For web services, use an IP-restricted API key.
For client-side services, use an HTTP referrer-restricted API key.
For Maps and Places SDK for Android or iOS, use an Android/iOS restricted API key.
To learn more on API key restrictions for Google Maps APIs please check out these resources:
https://developers.google.com/maps/faq#keysystem
https://developers.google.com/maps/api-key-best-practices#restrict_apikey
Hope this clarifies your question!
I have the same issue, I'm using Android RN application but this could help to any mobile app (Native or React native), the issues come up with you are hardcoding your API KEY (this case google places API into your source code), in order to avoid it you should remove it and add it as System/environment variable, depend of what OS you using OS MAC or Windows, or you CI/ CD if you are delivery you app through it. I solved with the steps below:
I have to setup my System Environment variables in my local
environment in my case I'm using MacOS, Open terminal and run
export GOOGLE_PLACES_ANDROID_API_KEY=Insert_API_KEY_here
(optional but this is better)or copy it in ~/.bash_profile
Make sure my system/environment variable is there- use in the
terminal "printenv" -this will list those and there should be your
api key
GOOGLE_PLACES_ANDROID_API_KEY
Add android/gradle.properties the following line
# GOOGLE PLACES (we will replace this value DON'T COPY YOUR API KEY HERE)
GOOGLE_PLACES_ANDROID_API_KEY=HiHackerNoMyKey
Add the following lines in app/build.gradle inside defaultConfig
defaultConfig {
buildConfigField("String", "GOOGLE_PLACES_ANDROID_API_KEY", "\"${GOOGLE_PLACES_ANDROID_API_KEY}\"")
}
in my case I'm using Appcenter as CI so I added this line if we are building in CI and my CI should have my APIKEY in my system/environment variable already setup
[buildConfigField("String", "GOOGLE_PLACES_ANDROID_API_KEY", "\"${System.env.GOOGLE_PLACES_ANDROID_API_KEY}\"")](url)
and you can call it using java
Log.i(TAG, BuildConfig.GOOGLE_PLACES_ANDROID_API_KEY);
more reference
https://developer.android.com/studio/build/gradle-tips#simplify-app-development
I hope this helps!!
In my app I need to use Google Cloud Text to Speech. I add sdk via gralde
implementation 'com.google.cloud:google-cloud-texttospeech:0.100.0-beta'.
After that i am not understanding how to add credentials to my android app. In Cloud console I created and added billing for project and downloaded service account json file. But where can i add in android app ? If i run code without adding the app I'm getting an exception
" 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 "
https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech/Speech
Here you can see how to add credentials
Below is a TTS sample project that I created with reference to Google Cloud STT
https://github.com/ivso0001/GoogleCloudTextToSpeech/tree/master
I am implementing the "login by WeChat" feature for my Android app.
I followed all the steps on the official developer guide, however, I am consistently getting the error code ERR_BAN in my onResp function in the WXEntryActivity class.
I wonder what does ERR_BAN mean?
What are the possible root causes?
ERR_BAN error is probably happening because you have added the incorrect app signature.
In order to retrieve the correct signature you must download the Android Signature tool from the following link
https://res.wx.qq.com/open/zh_CN/htmledition/res/dev/download/sdk/Gen_Signature_Android2.apk
Install the app, add your app package id and add the generated key to the we chat admin interface:
https://open.weixin.qq.com/cgi-bin/index?t=home/index&lang=zh_CN
(hint: use the chrome translate plugin to navigate on the site, as it is in chinese only)
So I'm trying to figure out the Google login system using Ionic, Googleplus plugin & Firebase. I set everything up according to the following tutorial:
https://github.com/EddyVerbruggen/cordova-plugin-googleplus
Then I ran the code on my phone as Ionic-run Android. When I do that I get an error 10. I looked it up and according to the following link:
https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/243
It seems like it's an issue with the debug version and the key? In Firebase, I set up an Android project with the debug key but I didn't add the Google.services.json or add the code they told me to add in my build.gradle file because I get an error. I also activated the google sign in method. Then I copied the demo app index. I'm not sure If I missed a step or didn't set something up correctly.
In case it's helpful for anyone else, I spent a lot of time troubleshooting this issue on Android. You need to make sure that your client_id for a credential of type "Web application" is used even though the SHA1 certificate hash you generate is associated with an OAuth2 credential of type Android. I was using the Android client_id instead of the Web application one. More info here: https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/425
I fixed it by using a different project, not really sure what changed.