Giter VIP home page Giter VIP logo

android-basic-samples's Introduction

Google Play game services - Android Samples

Copyright (C) 2014 Google Inc.

Contents

These are the Android samples for Google Play game services.

  • CollectAllTheStars2. Demonstrates how to use the Snapshots feature to save game data. The sample signs the user in, synchronizes their data from a named Snapshot, then updates the UI to reflect the game state saved in the Snapshot.

  • TypeANumber. Demonstrates how to use leaderboards, achievements, events, and friends. In this exciting game, you type the score you think you deserve. But wait! There is a twist. If you are playing in easy mode, you get the score you requested. However, if you are playing in hard mode, you only get half! (tough game, we know). You can also check how your friends perform in this game by checking out social leaderboards.

How to run a sample

  1. Set up the project in the Developer Console by following these instructions. Note your package name and the application ID of the project!

  2. For the Type a Number sample, you need to create leaderboards/achievements. (You can see the ones that the sample needs in its res/values/ids.xml file.) You can create them two ways:

    1. Add them via the Developer console.
    2. Use this utility, which will automatically create them for you.

Building using Android Studio...

  1. Open Android Studio and launch the Android SDK manager from it (Tools | Android | SDK Manager)
  2. Ensure the following components are installed and updated to the latest version.
    1. Android SDK Platform-Tools
    2. Android Support Repository
    3. Google Repository
  3. Return to Android Studio and select Open an existing Android Studio project
  4. Select the android-basic-samples directory.

Modify IDs, compile and run

To set up a sample:

  1. Change the applicationId in the build.gradle file to your own package name (ie - com.example.package.name) (the same one you registered in Developer Console!). You will have to update the build.gradle file for each sample you want to run. There is no need to edit the AndroidManifest.xml file.
  2. In the Developer console, select a resource type (Achievements, Events, Leaderboards) and click "Get Resources". Copy the contents from the console and replace the contents of res/values/ids.xml.
    1. If you are running Android Studio, check the TODO window to see if there are any remaining tasks.
  3. Compile and run.

IMPORTANT: make sure to sign your apk with the same certificate as the one whose fingerprint you configured on Developer Console, otherwise you will see errors.

IMPORTANT: if you are testing an unpublished game, make sure that the account you intend to sign in with (the account on the test device) is listed as a tester in the project on your Developer Console setup (check the list in the "Testing" section), otherwise the server will act as though your project did not exist and return errors like 'Failed to sign in. Please check your network connection and try again.'

Building

To build the samples after you have applied the changes above, you can use the build/run option in Android Studio, or build directly from the command line if you prefer.

IMPORTANT Ensure you have set the ANDROID_HOME environment variable.

cd /path/to/android-basic-samples
export ANDROID_HOME = /path/to/android/sdk
./gradlew build

Support

First of all, take a look at our troubleshooting guide. Most setup issues can be solved by following this guide.

If your question is not answered by the troubleshooting guide, we encourage you to post your question to stackoverflow.com. Our team answers questions there regularly.

Samples written by Bruno Oliveira with contributions from Wolff.* Feel free to add us to your circles on Google Plus and pester us to fix stuff that's broken or answer a question on stackoverflow :-)

Special Thanks

  • To ligi for contributing the initial Gradle build files
  • To bechhansen for fixing a bug in GameHelper where the turn-based match was being lost when a non-Games client connected.

android-basic-samples's People

Contributors

alex-dorokhov avatar bechhansen avatar btco avatar claywilkinson avatar danielrearden avatar dturner avatar geertjan-apptornado avatar gevorg-kopalyan avatar gguuss avatar grantkemp avatar grantland avatar hak avatar iannilewis avatar idanlv avatar inl1ne avatar jansoren avatar krez01 avatar ligi avatar masteage avatar msmaurizio avatar mwgray avatar naokigoogle avatar ndbroadbent avatar olehkuznetsov avatar redls avatar samtstern avatar thedmail avatar tjohns avatar william-ferguson-au avatar wolffg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-basic-samples's Issues

Unclear workflow with SIGN_IN_FAILED

Get the following problem with SignIn workflow.

  • setup GameHelper in onCreate
  • let helper attempt signing in onStart - it fails
  • initiate userSignIn, it fails when multiple Google accounts are present with resolution showing popup. This resolution is started as mConnectionResult.startResolutionForResult(mActivity, RC_RESOLVE);
  • Receive in onActivityResult SIGN_IN_FAILED error with no additional details because onConnected and onConnectionFailed method implemented in GameHelper were not called - signin attempt failed somewhere inside ConnectionResult

Any way to know what went wrong and why signin failed?

new gamehelper bug detected in sign in

onstart the intent to choose the account appears over and over y don't connect never.

the same goes in the method beginUserInitiatedSignIn.

with the previous version did not have this problem.

02-19 02:01:14.591: D/GameHelper(9425): GameHelper: Setup: requested clients: 1
02-19 02:01:14.621: D/GameHelper(9425): GameHelper: onStart
02-19 02:01:14.621: D/GameHelper(9425): GameHelper: Connecting client.
02-19 02:01:15.442: D/GameHelper(9425): GameHelper: onConnectionFailed
02-19 02:01:15.442: D/GameHelper(9425): GameHelper: Connection failure:
02-19 02:01:15.442: D/GameHelper(9425): GameHelper: - code: SIGN_IN_REQUIRED(4)
02-19 02:01:15.442: D/GameHelper(9425): GameHelper: - resolvable: true
02-19 02:01:15.442: D/GameHelper(9425): GameHelper: - details: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{40515c60: android.os.BinderProxy@40551f90}}
02-19 02:01:15.442: D/GameHelper(9425): GameHelper: onConnectionFailed: WILL resolve because we have below the max# of attempts, 0 < 3
02-19 02:01:15.442: D/GameHelper(9425): GameHelper: onConnectionFailed: resolving problem...
02-19 02:01:15.442: D/GameHelper(9425): GameHelper: resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{40515c60: android.os.BinderProxy@40551f90}}
02-19 02:01:15.442: D/GameHelper(9425): GameHelper: Result has resolution. Starting it.
02-19 02:01:21.108: D/GameHelper(9425): GameHelper: onStop
02-19 02:01:21.108: D/GameHelper(9425): GameHelper: Client already disconnected when we got onStop.
02-19 02:01:46.973: D/GameHelper(9425): GameHelper: onStart

NPE in `GameHelper.onConnectionFailed`

Null pointer exception occured in GameHelper.onConeectionFailed.

03-31 10:49:14.101: E/AndroidRuntime(12577): FATAL EXCEPTION: main
03-31 10:49:14.101: E/AndroidRuntime(12577): Process: com.lazybeeinc.ZombieAway, PID: 12577
03-31 10:49:14.101: E/AndroidRuntime(12577): java.lang.NullPointerException
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.google.android.gms.common.ConnectionResult.startResolutionForResult(Unknown Source)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.google.example.games.basegameutils.GameHelper.resolveConnectionResult(GameHelper.java:856)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.google.example.games.basegameutils.GameHelper.onConnectionFailed(GameHelper.java:832)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.google.android.gms.internal.ei.a(Unknown Source)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.google.android.gms.common.api.b.dy(Unknown Source)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.google.android.gms.common.api.b.d(Unknown Source)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.google.android.gms.common.api.b$4.onConnectionFailed(Unknown Source)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.google.android.gms.internal.ei.a(Unknown Source)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.google.android.gms.internal.eh$h.b(Unknown Source)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.google.android.gms.internal.eh$h.a(Unknown Source)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.google.android.gms.internal.eh$b.ec(Unknown Source)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.google.android.gms.internal.eh$a.handleMessage(Unknown Source)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at android.os.Handler.dispatchMessage(Handler.java:102)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at android.os.Looper.loop(Looper.java:136)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at android.app.ActivityThread.main(ActivityThread.java:5017)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at java.lang.reflect.Method.invokeNative(Native Method)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at java.lang.reflect.Method.invoke(Method.java:515)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-31 10:49:14.101: E/AndroidRuntime(12577):    at dalvik.system.NativeStart.main(Native Method)

GameHelper, NullPointerException at resolveConnectionResult()

java.lang.NullPointerException at
com.google.android.gms.common.ConnectionResult.startResolutionForResult(Unknown Source)
at com.android.gplay.a.h(GameHelper.java:856)
at com.android.gplay.a.onConnectionFailed(GameHelper.java:832)

Android 2.3.7. ANR from client.

Crash when the user signs in twice on slow connections

The GameHelper class should deal with the case that the user initiates the sign in flow twice. Eg when the connection is slow the user might hit the sign in twice.

The exception is:

java.lang.IllegalStateException: GameHelper: operation attempted at incorrect state. Operation: beginUserInitiatedSignIn. State: CONNECTING. Expected state: DISCONNECTED.

GameHelper bug detected on sign in

We see issues when the game helper cannot connect during sign in (such as when your device is in airplane mode). It keeps retrying causing the application to lock. Here is the log that asks us to report the bug:

D/GoogleGameHelper( 9622): GameHelper: onConnectionFailed
D/GoogleGameHelper( 9622): GameHelper: Connection failure:
D/GoogleGameHelper( 9622): GameHelper: - code: SIGN_IN_REQUIRED(4)
D/GoogleGameHelper( 9622): GameHelper: - resolvable: true
D/GoogleGameHelper( 9622): GameHelper: - details: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{42a24660: android.os.BinderProxy@42a18298}}
D/GoogleGameHelper( 9622): GameHelper: onConnectionFailed: since user initiated sign-in, resolving problem.
W/GoogleGameHelper( 9622): !!! GameHelper WARNING: GameHelper: bug detected. Please report it at our bug tracker https://github.com/playgameservices/android-samples/issues. Please include the last couple hundred lines of logcat output and describe the operation that caused this. Explanation: resolveConnectionResult should only be called when connecting. Proceeding anyway.Operation: resolveConnectionResult. State: DISCONNECTED. Expected state: CONNECTING.
D/GoogleGameHelper( 9622): GameHelper: resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{42a24660: android.os.BinderProxy@42a18298}}
D/GoogleGameHelper( 9622): GameHelper: Result has resolution. Starting it.

Here are the log messages above which may or may not help:

D/CoreActivity( 9622): Java::onActivityResult - 9001
D/GoogleGameHelper( 9622): GameHelper: onActivityResult: req=RC_RESOLVE, resp=SIGN_IN_FAILED
D/GoogleGameHelper( 9622): GameHelper: onActivityResult: ignoring because state isn't STATE_CONNECTING (it's DISCONNECTED)
D/CoreActivity( 9622): Java::onResume
D/FacebookHelper( 9622): Facebook: openSession with state: CLOSED_LOGIN_FAILED
D/GoogleGameHelper( 9622): GameHelper: onStart, state = DISCONNECTED
D/GoogleGameHelper( 9622): GameHelper: onStart: Not connecting (user specifically signed out).
D/KeyguardViewMediator( 501): setHidden false
I/SurfaceFlinger( 155): id=171 Removed idx=4 MapSz=4
D/KeyguardViewMediator( 501): setHidden false
I/SurfaceFlinger( 155): id=171 Removed idx=-2 MapSz=4
D/overlay ( 155): FROM_STATE = OV_BYPASS_3_LAYER TO_STATE = OV_CLOSED
D/overlay ( 155): FROM_STATE = OV_CLOSED TO_STATE = OV_BYPASS_2_LAYER
E/overlay ( 155): Failed to call ioctl MSMFB_OVERLAY_SET err=Operation not permitted
E/overlay ( 155): MdpCtrl failed to setOverlay, restoring last known good ov info
E/overlay ( 155): == Bad OVInfo is: mdp_overlay z=0 fg=1 alpha=255 mask=-1 flags=0x840000 id=-1
E/overlay ( 155): src msmfb_img w=480 h=800 format=0 MDP_RGB_565
E/overlay ( 155): src_rect mdp_rect x=0 y=0 w=480 h=800
E/overlay ( 155): dst_rect mdp_rect x=0 y=0 w=480 h=800
E/overlay ( 155): user_data user_data cnt=8
E/overlay ( 155): i=0 val=0
E/overlay ( 155): i=1 val=0
E/overlay ( 155): i=2 val=0
E/overlay ( 155): i=3 val=0
E/overlay ( 155): i=4 val=0
E/overlay ( 155): i=5 val=0
E/overlay ( 155): i=6 val=0
E/overlay ( 155): i=7 val=0
E/overlay ( 155): == Last good known OVInfo is: mdp_overlay z=0 fg=0 alpha=0 mask=0 flags=0x0 id=-1
E/overlay ( 155): src msmfb_img w=0 h=0 format=0 MDP_RGB_565
E/overlay ( 155): src_rect mdp_rect x=0 y=0 w=0 h=0
E/overlay ( 155): dst_rect mdp_rect x=0 y=0 w=0 h=0
E/overlay ( 155): user_data user_data cnt=8
E/overlay ( 155): i=0 val=0
E/overlay ( 155): i=1 val=0
E/overlay ( 155): i=2 val=0
E/overlay ( 155): i=3 val=0
E/overlay ( 155): i=4 val=0
E/overlay ( 155): i=5 val=0
E/overlay ( 155): i=6 val=0
E/overlay ( 155): i=7 val=0
E/overlay ( 155): MdpCtrl Lkgo ov has id -1, will not restore
E/overlay ( 155): Ctrl commit failed set overlay
E/overlay ( 155): OverlayImpl p0 failed to commit
E/overlay ( 155): Overlay commit failed
E/hwcomposer( 155): prepare: commit failed
D/overlay ( 155): FROM_STATE = OV_BYPASS_2_LAYER TO_STATE = OV_CLOSED
D/overlay ( 155): FROM_STATE = OV_CLOSED TO_STATE = OV_BYPASS_2_LAYER
D/void AppDelegate::applicationWillEnterForeground( 9622): Activiating and Starting Animation
V/MediaPlayer( 9622): start
V/MediaPlayerService( 158): [3] setLooping(0)
V/StagefrightPlayer( 158): setLooping
V/MediaPlayerService( 158): [3] setVolume(0.200000, 0.200000)
V/AudioSink( 158): setVolume(0.200000, 0.200000): 0x41c7ec48
V/MediaPlayerService( 158): [3] setAuxEffectSendLevel(0.000000)
V/AudioSink( 158): setAuxEffectSendLevel(0.000000)
V/MediaPlayerService( 158): [3] start
V/StagefrightPlayer( 158): setLooping
V/StagefrightPlayer( 158): start
V/AwesomePlayer( 158): play
V/AwesomePlayer( 158): AwesomePlayer::play_l():: This is not a DRM content
V/AwesomePlayer( 158): startAudioPlayer_l, sendErrorNotification (0)
V/AudioSink( 158): resumeSession
W/AudioPolicyManagerBase( 158): changeRefCount() invalid delta -1 for stream 3, refCount 0
V/AudioPolicyManagerBase( 158): startOutput() output 56, stream 3, session 0
V/AudioPolicyManagerBase( 158): changeRefCount() stream 3, count 1
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
V/AudioPolicyManagerBase( 158): getNewDevice() selected device 2
E/AudioPolicyManagerBase( 158): startOutput() LPA mute
V/AudioHardwareMSM8660( 158): AudioSessionOutLPA::setParameters() lpa_mute=on
V/AudioHardwareMSM8660( 158): AudioSessionOutLPA::setVolume(0.000000)
V/AudioHardwareMSM8660( 158): Setting session volume to 0.000000 (available range is 0 to 100)
V/AudioHardwareMSM8660( 158): msm_set_volume(0.000000) succeeded
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
V/AudioPolicyManagerBase( 158): getNewDevice() selected device 2
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
V/AudioPolicyManagerBase( 158): getNewDevice() selected device 2
V/AudioPolicyManagerBase( 158): setOutputDevice() output 56 device 0002 force 1 delayMs 0
V/AudioPolicyManagerBase( 158): setOutputDevice() prevDevice 0002
V/AudioPolicyManagerBase( 158): setOutputDevice() changing device(0x2)
V/AudioHardwareMSM8660( 158): AudioSessionOutLPA::setParameters() routing=2
V/AudioHardwareMSM8660( 158): set output routing 2
E/AudioHardwareMSM8660( 158): outputDev=2, inputDev=0
V/AudioHardwareMSM8660( 158): cur_rx:2 => rx:2, cur_tx:3 => tx:3 is seleted in doRouting
V/AudioHardwareMSM8660( 158): doRouting done
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
V/AudioPolicyManagerBase( 158): getNewDevice() selected device 2
V/AudioPolicyManagerBase( 158): checkAndSetVolume() cannot set stream 6 volume with force use = 0 for comm
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
E/AudioPolicyManagerBase( 158): stream type [10], return media stratege
V/AudioPolicyManagerBase( 158): getNewDevice() selected device 2
V/AudioPolicyManagerBase( 158): checkOutputForStrategy(0002,0002,3)
V/AwesomePlayer( 158): addBatteryData
D/activateApp( 9622): activateApp()

GamesClient.disconnect ANR

I get the occasional "Application Not Responding" like:

ANR Broadcast of Intent { act=android.intent.action.SCREEN_OFF

With consistent user messages:

"after lock screen"
"error appearing after lockscreen"

Stack trace:

"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41510ca8 self=0x2a00f4a8
| sysTid=12485 nice=-6 sched=0/0 cgrp=apps handle=1073811796
| state=S schedstat=( 0 0 0 ) utm=7689 stm=676 core=0
#00 pc 00020588 /system/lib/libc.so (__ioctl+8)
#01 pc 0002cb37 /system/lib/libc.so (ioctl+14)
#02 pc 0001d375 /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+140)
#03 pc 0001d85f /system/lib/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+42)
#04 pc 0001da67 /system/lib/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+118)
#05 pc 00019719 /system/lib/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+30)
#06 pc 00070c99 /system/lib/libandroid_runtime.so
#07 pc 0001dbcc /system/lib/libdvm.so (dvmPlatformInvoke+112)
#08 pc 0004e123 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#09 pc 00026fe0 /system/lib/libdvm.so
#10 pc 0002dfa0 /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#11 pc 0002b638 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#12 pc 00060865 /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+392)
#13 pc 000007c7 /system/lib/libdvm.so
#14 pc 00026fe0 /system/lib/libdvm.so
#15 pc 0002dfa0 /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#16 pc 0002b638 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#17 pc 00060581 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+336)
#18 pc 00049d0b /system/lib/libdvm.so
#19 pc 0004cde7 /system/lib/libandroid_runtime.so
#20 pc 0004db0b /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+354)
#21 pc 00001c4d /system/bin/app_process
#22 pc 0000e34b /system/lib/libc.so (__libc_init+50)
#23 pc 000017f4 /system/bin/app_process
at android.os.BinderProxy.transact(Native Method)
at com.google.android.gms.internal.er$a$a.bT((null):-1)
at com.google.android.gms.internal.em.disconnect((null):-1)
at com.google.android.gms.games.GamesClient.disconnect((null):-1)
at com.google.example.games.basegameutils.GameHelper.killConnections(GameHelper.java:508)
at com.google.example.games.basegameutils.GameHelper.onStop(GameHelper.java:391)
at com.google.example.games.basegameutils.BaseGameActivity.onStop(BaseGameActivity.java:117)
at (mypackagename).BaseActivity.onStop(BaseActivity.java:780)
at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1212)
at android.app.Activity.performStop(Activity.java:5376)
at android.app.ActivityThread.handleSleeping(ActivityThread.java:3302)
at android.app.ActivityThread.access$2900(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:126)
at dalvik.system.NativeStart.main(Native Method)

sign in popup closes app

hi. just want to ask for confirmation if this is normal. the connecting to google play game popup sign in, in gamehelper shows but not on top of the calling activity

is this normal?

i tried to modify gamehelper setup() with extra View parameter so i could call buulder.setviewforpopups() but it doesnt work. the calling activity gets hidden while the sign in popup shows

Default waiting UI configuration issue

Surprisingly after room creation MIN_PLAYER value dose'nt work at all in this code that is for default room UI.

final int MIN_PLAYERS = 2;
Intent i = getGamesClient().getRealTimeWaitingRoomIntent(room, MIN_PLAYERS);
startActivityForResult(i, RC_WAITING_ROOM);

if i set MIN_PLAYERS = 3; then nothing will change and game starts immediately after 2 players.

PlusClient.getCurrentPerson() returns null, but only every now and again.

Some of my users devices are reporting a NullPointerException when fetching the Person object. It is attempted straight away after onSignInSucceeded() listener call.

Upon looking at the PlusClient.getCurrentPerson() docs it states that "This method can return null if the required scopes weren't specified in the PlusClient.Builder, or if there was a network error while connecting"

.... But GameHelper.setup() uses the GameHelper.CLIENT_ALL scope.

Any idea what could cause this?

"Game Features" banner in Play Store listing

Hi,

Our game implementing Google Play Game have now been live on the Play Store for a week, however I was expecting to see the "Game Features" banner appearing on the game listing page, like for other Play Game apps.

Any idea when that could happen ?
Thanks

Folder cannot be named aux in windows

With the new "aux" -folder, repository is no longer cloneable to Windows environment, since aux is illegal directory name.

http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words

Error:

Cloning into 'googleplay/android-samples'...
remote: Counting objects: 861, done.
remote: Compressing objects: 100% (418/418), done.
remote: Total 861 (delta 272), reused 804 (delta 224)
Receiving objects: 100% (861/861), 1.69 MiB | 582.00 KiB/s, done.
Resolving deltas: 100% (272/272), done.
Checking connectivity... done
fatal: cannot create directory at 'aux': Invalid argument

thred-safe ?

Hi,
Are sendUnreliableRealTimeMessage and others thred-safe ?

Also, the service seems unreliable. Sometimes no notification is received, or the other player doesn't appear on my list on a quick match.

Auto Match Criteria configuration Problem in BittonClicker Sample

I changed auto-match criteria configuration as per my requirement

void startQuickGame() {
final int MIN_OPPONENTS = 1, MAX_OPPONENTS = 3;
Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(MIN_OPPONENTS,
MAX_OPPONENTS, 0);
RoomConfig.Builder rtmConfigBuilder = RoomConfig.builder(this);
rtmConfigBuilder.setMessageReceivedListener(this);
rtmConfigBuilder.setAutoMatchCriteria(autoMatchCriteria);
rtmConfigBuilder.setRoomStatusUpdateListener(this);

getGamesClient().createRoom(rtmConfigBuilder.build());
}

but game still starts after 1(one) opponent (as set MIN_OPPONENT=1) . onRoomConnected() callback is called right after 1 opponent and did not wait for further opponents (as we set in MAX_OPPONETS.=3).

i also tried with my own waiting room UI and add a time delay. after that delay game will starts with available opponents within min and max opponent limit. but this will never happen ...
i am confused. :(

(client)' ~ Failed to receive dispatch signal. status=-11

cocos2d-x3.0rc0 + android ndk9 + include google play services lib + copy

BaseGameActivity.java
GameHelper.java
GameHelperUtils.java
to my project

  • 03-31 12:04:12.242: E/dalvikvm(22332): Could not find class 'com.google.android.gms.internal.gd$b', referenced from method com.google.android.gms.internal.gd.a

*03-31 12:04:13.871: E/GooglePlayServicesUtil(22332): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

*03-31 10:29:40.246: E/NativeActivity(19927): channel '407dc758 com.xx/com.xx.Cocos2dxActivity (client)' ~ Failed to receive dispatch signal. status=-11

BaseGameUtils shows Unknown Error

Hi,
I have installed BaseGameUtils with another MainActivity project in sdk sample and renamed package name and app_id. when I want to login G+ by touch login button on the Button Clicker 2000 screen, it returned Unknown error dialog and eclipse console log showed: Sign-in failed.
What can I do next?

Thanks!
2013-05-23 11 03 34

Client is not connected inside onConnected callback

Here is the interesting problem I can't reproduce, but keep getting crash reports from my users.
Basically the error happens onSigninSucceed when I register to listen to invitations and it throws illegal state, because Google client is not connecter. How it can not be connected if it is done from onConnected callback?

Here is a full stack:

java.lang.IllegalStateException: GoogleApiClient must be connected.
       at com.google.android.gms.internal.eg.a()
       at com.google.android.gms.games.Games.j()
       at com.google.android.gms.internal.fv.registerInvitationListener()
       at com.giderosmobile.android.plugins.googleplaygame.GGooglePlay.onSignInSucceeded(GGooglePlay.java:813)
       at com.giderosmobile.android.plugins.googleplaygame.GameHelper.notifyListener(GameHelper.java:541)
       at com.giderosmobile.android.plugins.googleplaygame.GameHelper.succeedSignIn(GameHelper.java:652)
       at com.giderosmobile.android.plugins.googleplaygame.GameHelper.onConnected(GameHelper.java:643)
       at com.google.android.gms.internal.dx.b()
       at com.google.android.gms.common.api.GoogleApiClient.bn()
       at com.google.android.gms.common.api.GoogleApiClient.f()
       at com.google.android.gms.common.api.GoogleApiClient$2.onConnected()
       at com.google.android.gms.internal.dx.b()
       at com.google.android.gms.internal.dx.bT()
       at com.google.android.gms.internal.dw$h.b()
       at com.google.android.gms.internal.dw$h.b()
       at com.google.android.gms.internal.dw$b.bR()
       at com.google.android.gms.internal.dw$a.handleMessage()
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:4921)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:511)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
       at dalvik.system.NativeStart.main(NativeStart.java)

API bugs ?

Hi again,
First, is there a better place to report bugs/issues about the Play Games Services API ?

When I call room.getCreatorId(), (to start a quick game), the answer is different for the different players !! The room has the same ID for all players but the creator is reported differently by the different players (each player reports himself as the creator).

Also, when onActivityResult is called as a result of the Waiting Room, which happens after onRoomConnected() is called, the corresponding room instance just reports the current player when I call getParticipants(). If I call the same function room.getParticipants() just before, from onRoomConnected(), I get the full list of participants. This is weird.

Operation: succeedSignIn Shouldn't Work in DISCONNECTED State

While running my app, this warning occurred. I'm not sure where I should include the logcat output. Let me know and I will upload it.

GameHelper WARNING: GameHelper: bug detected. Please report it at our bug tracker

https://github.com/playgameservices/android-samples/issues. Please include the last couple hundred lines of

logcat output and describe the operation that caused this. Explanation: succeedSignIn should only get called

in the connecting or connected state. Proceeding anyway.Operation: succeedSignIn. State: DISCONNECTED.

Expected states: CONNECTING CONNECTED.

Check the current value of an incremental achievement

I'm taking a look at pushAccomplishments function in TypeANumber sample code and I realised, when you update the value of an incremental achievement, it isn't checked if its current value is greater the current value of mBoredSteps:

if (mOutbox.mBoredSteps > 0) {
      getGamesClient().incrementAchievement(getString(R.string.achievement_really_bored), mOutbox.mBoredSteps);
      getGamesClient().incrementAchievement(getString(R.string.achievement_bored),
                    mOutbox.mBoredSteps);
}

I've actually checked, for instance, if the variable mBoredSteps value is 2 and the current value of the achievement is 9, this value will be replaced and it will be 2.

Unkown error when canceling account list

Hello,

so I noticed, when you have multiple google accounts registered with device (in settings), after you request sign in, you will be prompted with the list of google accounts, an option to create new account and button "cancel". After you press cancel, you recieve error code 4, which will be interpreted by the library as dialog with text "unknown error". Now as I don't know what is the solution for this, I temporarily disabled dialogs for error code 4. Shouldn't be this fixed?

Also, is there some nice way to alert user when trying to sign in without internet connection? Will API somehow let me know, so I can show alert? (Or proper way is on sign in request check internet status?) Another question I have is, what will happen if user is signed in, then turns the internet off and I submit score with the API, will the submitted score be somehow stored? Or should I also check internet status when sending score with API (even when user is signed in)? Last thing on my mind is, is somewhere on the internet the list of error codes? Because i.e. I recieved error code 10002, and I have no clue what it means.

Quick RTMPHelper.java guide

Hi Bruno, I know that RtmpHelper.java is a experimental class, but I was wondering if you could throw up a quick guide that shows how to use it in our own Activities. Thanks. I assume that the RTMP stands for Real-Time Multiplayer.

Layout Problem

Hi,
I am trying leaderboard feature,
but I can't find show leaderboard button,
after figure out,
It is screen-size problem,
Does anyone fix that?
Thanks!

-1

IllegalArgumentException: View not attached to window manager

I am starting and stopping GameHelper in the correct way.

  • setup() in onCreate(),
  • onStart() and onStop() methods executed in the onStart and onStop.
  • onActivityResult called in onActivityResult.

I have received 3 reports in the past 2 days of the following stacktrace:

java.lang.RuntimeException: Unable to stop activity {chesspresso.client.android.p/azurewing.android.activity.main.ChessMainActivity}: java.lang.IllegalArgumentException: View not attached to window manager
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:2806)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:2851)
at android.app.ActivityThread.access$900(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1164)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: View not attached to window manager
at android.os.Parcel.readException(Parcel.java:1331)
at android.os.Parcel.readException(Parcel.java:1281)
at com.google.android.gms.internal.bu$a$a.av(Unknown Source)
at com.google.android.gms.internal.bp.disconnect(Unknown Source)
at com.google.android.gms.games.GamesClient.disconnect(Unknown Source)
at com.google.example.games.basegameutils.GameHelper.killConnections(GameHelper.java:507)
at com.google.example.games.basegameutils.GameHelper.onStop(GameHelper.java:390)
at azurewing.android.activity.LoggedInActivity.onStop(LoggedInActivity.java:66)
at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1174)
at android.app.Activity.performStop(Activity.java:4608)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:2803)
... 11 more

Using the GameHelper spinning circle that never goes away when network connectivity is available but reachability is not.

When using the GameHelper I've come across a problem when I am connected to a WiFi network that requires sign on to access the internet. This is a very simple way to test that the phone has connectivity but cannot reach the servers. This behavior could happen in the real world for a variety of reasons. One being that the GPGS servers are down, or unreachable.

When launching the app I see the "Google Play Game Services" Popup followed by a spinning "working" circle that never goes away. This blocks access to our game when this happens on start.

D/GameHelper(16101): GameHelper: onConnectionFailed
D/GameHelper(16101): GameHelper: Connection failure:
D/GameHelper(16101): GameHelper: - code: SIGN_IN_REQUIRED(4)
D/GameHelper(16101): GameHelper: - resolvable: true
D/GameHelper(16101): GameHelper: - details: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{41e4a2b0: android.os.BinderProxy@41edf378}}
D/GameHelper(16101): GameHelper: onConnectionFailed: WILL resolve because we have below the max# of attempts, 0 < 2
D/GameHelper(16101): GameHelper: onConnectionFailed: resolving problem...
D/GameHelper(16101): GameHelper: resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{41e4a2b0: android.os.BinderProxy@41edf378}}
D/GameHelper(16101): GameHelper: Result has resolution. Starting it.

It appears that the helper is trying to resolve a sign in, with a sign in. However no timeout takes place with what is a reasonable period of time. I attempted to add my own timeout using Handler.postDelay() and testing if mExpectingResolution is still true. This could be used to detect the state that I mentioned, but even when I was able to force a dialog up indicating that there was a network error the spinning "working" circle remains on top of the dialogue. I tried both destroying and disconnecting GoogleApiClient, but neither got rid of the spinning "working" screen.

How would I go about flushing the screens on top of my game in this instance, or resetting the UI, or simply resetting the GoogleApiClient entirely? Either one of these would be acceptable.

Thank you!

onActivityResult fires with SIGN_IN_FAILED for multiple G+ accounts

I'm getting a weird behavior.
I have several Google accounts on my device.
I setup GameHelper in my onCreate providing a listener. in onStart I call gameHelper.onStart(activity);
So, wIth 'mConnectOnStart = true', gameHelper attempts to connect in onStart, but attempt fails firing onSignInFailed(). That resolves by showing a popup allowing to pick a Google account, but right after that I get onActivityResult called with SIGN_IN_FAILED error code. I suspect it comes from the failed attempt in onStart.

BaseGameActivity not working on eclipse

Hi
I followed the instructions to import Basegameutlis as a library and google play services.
I still can't get Eclipse to recognise BaseGameActivity

It just displays the error:
BaseGameActivity cannot be resolved to a type

Can you give clearer instructions what needs to happen to get it to work.

mConnectOnStart defaults to true

On ln 18 of the GameHelper

boolean mConnectOnStart = true;

This can't be right? As now my apps pop up the overlay on launch, not desired behavior at all.

I can force it to false for now, but is this the intended code?

Android Studio 0.5.3 and Gradle

I think what happened is that documentation was written for a beta version of Android Studio. Add in the moving target they call "Gradle", and you have a mess from the standpoint of someone trying to get up and running in Google Play services. Your documentation does not work for the "out-of-the-box" situation you have today. Not your fault. Documentation is obsolete the day you roll it out. You may get better numbers, if you treated the documentation the way you do the code...

Error Log...
Failed to refresh Gradle project 'BasicSamples'
The project is using an unsupported version of the Android Gradle plug-in (0.7.3).
Version 0.9.0 introduced incompatible changes in the build language.
Please read the migration guide to learn how to update your project.

Would it be possible to get updated docs based on the new situation with Gradle and Android Studio? The current situation is very discouraging to a developer considering using these services.

Thanks.

GameHelper should be a retained Fragment

While I understand that the effect is largely the same, it would seem to be more in line with best practices to have the GameHelper instance run as a Fragment with no View, setRetainInstance(true), and the onCreate(Bundle...) in BaseGameActivity to say something like:

mHelper = (GameHelper) getSupportFragmentManager().findFragmentByTag("gameHelper");

if (mHelper == null) {
    mHelper = new GameHelper();
    getSupportFragmentManager().beginTransaction().add(mHelper, "gameHelper").commit();
}

The main benefits of doing this are that we don't run any risk of leaking the activity (you can use getActivity() from within the fragment) and this can technically be used across multiple Activity instances (screen rotation!). You also get the lifecycle stuff (with the exception of onActivityResult) for free without needing to proxy.

I'd be happy to do the work if this makes sense. I've already done most of it.

Google Multiplayer peer Connection to room problem

Google Real_time Multiplayer RoomUpdateListener is not working properly as mentioned in document . RoomUpdateListener listener call back onpeerConnected is not triggerd one by one unless and until all Max Player are not connect to room.

IllegalStateException when recreating Google Play Activities

When the user is on a Play Activity (eg the achievements activity), closes the game and restarts the app the following exception occurs:

08-03 13:07:58.084: E/AndroidRuntime(32096): java.lang.IllegalStateException: GameHelper: operation attempted at incorrect state. Operation: connectCurrentClient. State: DISCONNECTED. Expected state: CONNECTING.
08-03 13:07:58.084: E/AndroidRuntime(32096):    at com.google.example.games.basegameutils.GameHelper.assertState(GameHelper.java:187)
08-03 13:07:58.084: E/AndroidRuntime(32096):    at com.google.example.games.basegameutils.GameHelper.connectCurrentClient(GameHelper.java:696)
08-03 13:07:58.084: E/AndroidRuntime(32096):    at com.google.example.games.basegameutils.GameHelper.connectNextClient(GameHelper.java:692)
08-03 13:07:58.084: E/AndroidRuntime(32096):    at com.google.example.games.basegameutils.GameHelper.onConnected(GameHelper.java:771)
08-03 13:07:58.084: E/AndroidRuntime(32096):    at com.google.android.gms.internal.p.k(Unknown Source)

(the line numbers in the stack trace don't match exactly)

In addition to starting the Google Play Activity, the app also initiates the regular background sign in for the user.

Maybe the Helper can not deal with this "double sign in"?

I am running the very latest GameHelper class from master.

Avatar image must be squared. ClientRequestInboxListActivit has crashed.

I had implemented sending gifts and requests and invoking inbox. I has tested with some friends. Some friends could send hearts to me. So I has uloaded my apk to Play. When one friend has send a request to me, my inbox has broken.

E/AndroidRuntime(29235): FATAL EXCEPTION: main
E/AndroidRuntime(29235): Process: com.google.android.gms.ui, PID: 29235
E/AndroidRuntime(29235): java.lang.IllegalArgumentException: Avatar image must be squared
E/AndroidRuntime(29235):    at bio.a(SourceFile:25)
E/AndroidRuntime(29235):    at big.a(SourceFile:284)
E/AndroidRuntime(29235):    at bib.run(SourceFile:614)
E/AndroidRuntime(29235):    at android.os.Handler.handleCallback(Handler.java:733)
E/AndroidRuntime(29235):    at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(29235):    at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(29235):    at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime(29235):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(29235):    at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(29235):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime(29235):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime(29235):    at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(  768):   Force finishing activity com.google.android.gms/.games.ui.client.requests.ClientRequestInboxListActivity
W/ActivityManager(  768):   Force finishing activity com.lazybeeinc.ZombieAway/.ZombieAway

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.