2

I have tried to integrate google play services into my app for several days now and I am completely frustrated. I could not integrate it to eclipse, so I decided to work with Android Studio from now on, so things there are new to me as well. I cannot get the samples from google to work (some dependency errors I guess because AS couldn't find R for example), so I tried to set up a new test project. But onConnectionFailed is called and I first get "Sign_In_Required" results and a window is prompted where I can tap my googleaccount and when I retry to start the app I get an "INTERNAL_ERROR" result or I am required to sign in again.

So what do I want from you? I want an idea what might went wrong and maybe some really good tutorials how to use google play services because the ones from google seem complicated (because they often do not seem to work if I try).

Androidmanifest:

<meta-data android:name="com.google.android.gms.games.APP_ID"
    android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

games-ids.xml:

<resources>
    <string name="app_id">(myappidnumber)</string>
    <string name="package_name">(packagename)</string>
</resources>

build.gradle:

dependencies {
...
    compile 'com.google.android.gms:play-services:8.4.0'
}

MainAcivity:

package (mypackage);

import android.content.IntentSender;
import android.os.Bundle;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;

import com.google.android.gms.drive.*;
import android.support.v4.app.FragmentActivity;
import android.util.Log;

public class MainActivity extends FragmentActivity implements GoogleApiClient.ConnectionCallbacks, OnConnectionFailedListener{

    private GoogleApiClient myClient;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

         myClient = new GoogleApiClient.Builder(this)
                 .enableAutoManage(this ,
                         this )
                .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
    }

    @Override
    public void onStart(){
        super.onStart();
        myClient.connect();
    }

    @Override
    public void onConnected(Bundle b) {

    }

    @Override
    public void onConnectionFailed(ConnectionResult result) {
        Log.d("CODE1", "onConnectionFailed() called, result: " + result);
    }

    @Override
    public void onConnectionSuspended(int result) {
    }
}
Zoe
  • 27,060
  • 21
  • 118
  • 148
  • have you read how to correctly work with google driver here? https://developers.google.com/drive/android/intro – tyczj Apr 11 '16 at 15:42
  • change your compile line in gradle file into compile 'com.google.android.gms:play-services:7.5.0' and see if it works – Davy Apr 11 '16 at 15:48
  • Unfortunately, it does not work. I have added Drive just for the purpose of testing, by the way. I need achievements, to backup game files and admob to display advertisement. I do not know entirely which APIs are required. When "Internal_error" is thrown, it also states "resolution=null" and "message=null" by the way. – TeaDrinkerJoe Apr 11 '16 at 18:25

1 Answers1

1

According to Daniel F:

  1. Making sure that you have registered the package name with its corresponding certificate fingerprint, and
  2. Are (re)using an already existing project, then you should check that this project has an product name and an email address (double check that one specially) associated with it, both to be found in the "consent screen" section.

Here is a youtube playlist for Android Studio 101 to guide you on how to use it.

You can also find the android training provided by google useful as it will provide sample and how to's (implementing different API, code sample and error codes).

Also here is a similar SO question that will guide you on implementing google play service in your app.

Community
  • 1
  • 1
Mr.Rebot
  • 6,703
  • 2
  • 16
  • 91