Google places API for android showing statusCode=ERROR_OPERATION_FAILED - android

I am using this tutorial to create a autocomplete search box. I have created a custom adapter to populate my autocomplete text box. the following code should give me autocomplete suggestions.
mGoogleApiClient = new GoogleApiClient.Builder(MainActivity.this)
.addApi(Places.GEO_DATA_API)
.enableAutoManage(this, GOOGLE_API_CLIENT_ID, this)
.addConnectionCallbacks(this)
.build();
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient,
constraint.toString(),
mBounds, null);
unfortunately this gives me an error:
{statusCode=ERROR_OPERATION_FAILED, resolution=null}
I checked the official documentation, there are no reference of ERROR_OPERATION_FAILED error.
There are no problems with my API key I guess, because I had another application with a working API key. I used the working API key in this application, still it is not working.
I tried turning off mobile data. Surprisingly the error is still there. The error comes instantly as I type (i.e. It looks like its not even going to the google service at all).
what could be the reason of this error?

The AndroidManifest.xml should include permission :
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
and tag
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version"/>

Related

ACL_ACCESS_DENIED Awareness API - Android

I am trying to integrate Awareness API on a new project and I am stuck with an error saying: ACL_ACCESS_DENIED Status Code: 7503.
I have integrated Awareness API on other projects as well, but the last time I encountered that error, it was due to the lack of declaration on a needed permission, for the DetectedActivity feature to work.
This time though, I am just using the Location feature of the Awareness API.
I have also tried to change API keys, regenerate them and even enable/disable the API itself, from Google API Console, but without any luck.
I also have a proper Google Services JSON file and the version of Play Services I am using is: 10.0.0
compile 'com.google.android.gms:play-services-awareness:10.0.0'
Below is the code I am using:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET"/>
<meta-data
android:name="com.google.android.awareness.API_KEY"
android:value="MY_API_KEY"/>
this.googleApiClient = GoogleApiClient.Builder(this)
.addApi(Awareness.API)
.addConnectionCallbacks(this)
.enableAutoManage(this, this)
.build()
Awareness
.SnapshotApi
.getLocation(googleApiClient)
.setResultCallback {
handleLocationResult(it)
}
I have done a lot of Google searching as well, but no hints other than a SO post talking about the same error on Emulators. I am not trying it on an Emulator. I am using a real device to test it.
If anyone has any ideas, I would be grateful!
Thanks in advance!
Apparently, AwarenessAPI does return such an error for different cases.
The Status Code: 7503 will be returned even if you:
Missing a Permission from your Manifest, such as the one for DetectedActivity
Have the Location setting off when requesting a Location snapshot (it does not cause the Location Settings dialog to pop-up)
I will leave it here, in case someone else stumbles upon such a case, in the future!

Android Appinvite Error Unfortunately Google Play Services has stopped

I am trying to implement App invites in my app. Here's the java code that I am using :
Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title))
.build();
startActivityForResult(intent, Constants.REQUEST_CODE_INVITE);
But, as soon as I am clicking on the button which executes this code, a dialog pops up saying 'Unfortunately, Google Play Services has stopped'.
I have tried disabling, uninstalling and installing google play services again, and even restarting the phone, but no use.
No Exception is shown in android studio logs, so I am not able to figure out the problem is.
Please help.
There are a few issues here, and I'd also you to validate values.
getString requires resources. Assuming you are calling this from in an activity, you need to call
getResources().getString(R.....). You are likely getting null
returned which would result in an exception.
Although there is only 1 required parameter, you should fill out a few more to make sure you have a reasonable invitation, specifically setMessage(). Also, you can use setAccount() if you know the account, otherwise it will prompt.
I would also validate the input values. For example, log the string value you get for R.string.invitation_title to make sure you have set this correctly before you call the builder.
I was making a silly mistake which was leading to the error.
I was not initializing the GoogleApiClient before sending out the intent. Don't know how I missed it.
Here's the code that I was missing :
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(AppInvite.API)
.enableAutoManage(this, this)
.build();
Hope it helps future visitors to this page.

HistoryApi.readDailyTotal() does not work on Wear device

I'm developing watch face for Android Wear. I want to show on the face the steps recorded only by the wear device. According to Google Documentation this is possible with HistoryApi.readDailyTotal()
According to the documentation:
The system does not require authorization to access the TYPE_STEP_COUNT_DELTA data type from the HistoryApi.readDailyTotal() method. This can be useful if you require step data for use in areas where you are unable to show the permissions panel (for example, Android Wear watch faces and activities or widget activities). For more information on how to use this data in a watch face, see Showing Information in Watch Faces.
Unfortunately this does not work for me - GoogleApiClient always returns Connection failed: 5 - This means:The client attempted to connect to the service with an invalid account name specified.
This is my client:
mFitnessApiClient = new GoogleApiClient.Builder(MyWatchFace.this)
.addApi(Fitness.HISTORY_API)
.addScope(Fitness.SCOPE_ACTIVITY_READ)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
Any idea how to tackle this problem? I'm facing hard time with this.
I've had similar issues getting the total on the wearable (local only), and this worked for me: do not add any scopes, and be sure to call useDefaultAccount. Hope this helps!
Ex:
mFitnessApiClient = new GoogleApiClient.Builder(MyWatchFace.this)
.addApi(Fitness.HISTORY_API)
// Do not add any scopes if using the client on the watch
.addConnectionCallbacks(this)
.useDefaultAccount() // Use the default account
.addOnConnectionFailedListener(this)
.build();

Autocomplete Google Places sample

I'm trying to run the Google Place Code Sample, but I am not able to do it.
I am receiving error messages like:
Error getting autocomplete prediction API call: Status{statusCode=TIMEOUT, resolution=null}
I added my Google Map V2 ApiKey to the Manifest, and signed the app with the right certificate, so it seems that the key could be here:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, 0 /* clientId */, this)
.addConnectionCallbacks(this)
.addApi(Places.GEO_DATA_API)
.build();
I am not sure what is supposed to be in the clientId slot, and there is not too much info out there. Just other people with the same problem but without solution.
By the way if somebody wants to take a look to the complete code it is here:
https://github.com/googlesamples/android-play-places/issues/3
This error can be caused by not enabling the Places API for Android in your Google Developer Console (This is different from the regular Places API).
It can also be caused if you set your API key using the old 'maps' identifier instead of com.google.android.geo.API_KEY, when adding the google meta-data to your application manifest.

Android - Google+ login

I'm following the tutorial from https://developers.google.com/+/mobile/android/sign-in?hl=pt-PT and i'm having some dificulties on enabling the login.
Right on step 2, i have copied to code to my login fragment (where i have the facebook login working smooth), and i get an error on Plus client:
- mPlusClient cannot be resolved to a variable
- The method setVisibleActivities(String, String) is undefined for the type PlusClient.Builder
- The constructor PlusClient.Builder(SplashFragment, SplashFragment, SplashFragment) is undefined
I cant understand where i'm failing, as i've followed the tutorial several times.
The tutorial had been updated in english version. You can check it from https://developers.google.com/+/mobile/android/getting-started?hl=en.
They use GoogleApiClient now.
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.build();
It appears the Portuguese version of that page has not been updated to the latest API, hence you are getting errors attempting to use the old API (which has since been deprecated). Consider using the english version instead.
You can also use Social-Auth Library to integrate multiple social platforms with ease...
SocialAuth Android is an Android version of popular SocialAuth Java library. Now you do not need to integrate multiple SDKs if you want to integrate your application with multiple social networks. You just need to add few lines of code after integrating the SocialAuth Android library in your app.
Social Auth

Categories

Resources