Reputation: 429
I'm trying to access Google Fit API on Android Wear to get user Goals and I faced followed problem.
//I'm runing on Android Wear 2.0 emulator.
If there is no account specified (via setAccountName) in Builder, I get "Invalid Account" error message.
If i set manually account name I receive
"com.android.tools.fd.runtime.BootstrapApplication has problem with availability of google play services. Try again.".
I used following code to do this:
mClient = new GoogleApiClient.Builder(this)
.addApi(Fitness.GOAL_API)
.addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ))
.addScope(new Scope(Scopes.FITNESS_LOCATION_READ))
.addConnectionCallbacks([...])
.addOnConnectionFailedListener(
new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult result) {
if (result.hasResolution()) {
try {
result.startResolutionForResult(ConfigAccount.this, request_code);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
} else {
GoogleApiAvailability.getInstance().getErrorDialog(ConfigAccount.this, result.getErrorCode(), request_code_error, new DialogInterface.OnCancelListener() {})
.build();
Every time the result.resolution in onConnectionFailed() is null. Error code is 5005 - UNKNOWN_AUTH_ERROR Because the resolution is null, the startResolutionOnResult and enableAutoManage does not work.
The credentials should be fine. Presented approach works on phone with Android 5.1.
Version of play services is 9.8.0. Downgrading the version didn't help.
Any Ideas how can I achieve my goal? Thanks.
Upvotes: 2
Views: 1106
Reputation: 429
I know it took some time to answer, but in Android Wear Dev Preview 4, Google added wear 2.0 authentication. It looks like other ways of login into google services are not supported on wearables.
Upvotes: 2
Reputation: 7781
From the FitnessStatusCodes
documentation, the Error code is 5005 - UNKNOWN_AUTH_ERRO
R is a status code denotes that an unknown error occurred while trying to obtain an OAuth token. So make sure you get your OAuth token properly.
Another possible cause of this error occurs if your app is not registered properly in google developer console.
It is stated in this thread that you might have registered app on Google developer Console using production keystore certificate fingerprint(SHA1) where as you are testing it on app which has debug keystore.
Here are the steps that you need to do.
For more information, check this thread and this SO question.
Upvotes: 2