I\'m trying to connect my game to Google paly service but it keep telling me connection failed with statusCode SIGN_IN_REQUIRED .
l
An easy solution is to simply create a test OAuth client ID
using Android's debug keystore SHA-1
.
Go to the API Console -> Credentials -> Create Credentials -> OAuth client ID -> Android
Get Debug SHA-1
C:\Program Files\Android\Android Studio\jre\bin
keytool -exportcert -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
Password
android
Enter SHA-1 -> Enter App Package Name -> Create
By default Android studio uses this keystore to sign the debug APK so it should work right away.
There is one additional and very important step that beginners like me often overlook in Android studio.
You manually need to specify the Keystore which is used to build and sign the APK when you run it via Android studio. This should be the same Keystore whose SHA1 certificate signature you have entered for generating API key in Google Developer Console.
Here is how you do it:
If you don't have an existing Keystore OR cannot find it, you can create one by going to BUILD -> Generate Signed APK -> Create new
After you have created the Keystore, you need to add it to your Project settings so that it is used to sign the APK. Goto File -> Project Structure -> Select your module (e.g: app) -> Signing
Then you need to specify the Signing Config that you created in Step 2, to Build Types
Hope this helps someone!
That solution wasn't seen on any document, for a beginner like me it needed to be mentioned,
Adding the missing permission :
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
to become :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.alnassre.ffeather.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/GdxTheme" >
<activity
android:name="com.alnassre.ffeather.android.AndroidLauncher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
</application>
</manifest>