我尝试将google play服务与我的团结安卓游戏集成。登录谷歌播放服务后,DDMS中出现以下日志消息,应用程序崩溃。
02-27 13:50:00.633 13419-13419/? D/AndroidNative﹕ GameHelper: onConnected: connected! client=1
02-27 13:50:00.633 13419-13419/? D/AndroidNative﹕ GameHelper: Connected clients updated to: 1
02-27 13:50:00.633 13419-13419/? D/AndroidNative﹕ GameHelper: connectNextClient: requested clients: 1, connected clients: 1
02-27 13:50:00.633 13419-13419/? D/AndroidNative﹕ GameHelper: Pending clients: 0
02-27 13:50:00.633 13419-13419/? D/AndroidNative﹕ GameHelper: All clients now connected. Sign-in successful!
02-27 13:50:00.633 13419-13419/? D/AndroidNative﹕ GameHelper: All requested clients connected. Sign-in succeeded!
02-27 13:50:00.633 13419-13419/? D/AndroidRuntime﹕ Shutting down VM
02-27 13:50:00.633 13419-13419/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x415baba8)
02-27 13:50:00.633 13419-13419/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.dokinkon.projectp, PID: 13419
java.lang.Error: FATAL EXCEPTION [main]
Unity version : 4.3.2f1
Device model : LGE Nexus 5
Device fingerprint: google/hammerhead/hammerhead:4.4.2/KOT49H/937116:user/release-keys
Caused by: java.lang.IllegalStateException: No AppStateClient. Did you request it at setup?
at com.google.example.games.basegameutils.GameHelper.getAppStateClient(GameHelper.java:294)
at com.android.gs.GameClientManager.onStateChange(GameClientManager.java:690)
at com.google.example.games.basegameutils.GameHelper.setState(GameHelper.java:272)
at com.google.example.games.basegameutils.GameHelper.succeedSignIn(GameHelper.java:813)
at com.google.example.games.basegameutils.GameHelper.connectNextClient(GameHelper.java:695)
at com.google.example.games.basegameutils.GameHelper.onConnected(GameHelper.java:805)
at com.google.android.gms.internal.k.y(Unknown Source)
at com.google.android.gms.internal.au.y(Unknown Source)
at com.google.android.gms.internal.k$f.a(Unknown Source)
at com.google.android.gms.internal.k$f.a(Unknown Source)
at com.google.android.gms.internal.k$b.D(Unknown Source)
at com.google.android.gms.internal.k$a.handleMessage(Unknown Source)
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 dalvik.system.NativeStart.main(Native Method)
我不知道“java.lang.IllegalStateException:没有AppStateClient。你在安装时请求了吗?”意思是。感谢。
答案 0 :(得分:0)
您需要添加APPSTATE客户端,如下所示:
//should be called on your application start
//best practice to call it only once. Any way other calls will be ignored by the plugin.
//if you want to use only Game service (Leader-boards, achievements) use GooglePlayConnection.CLIENT_GAMES
//if you want to use only Google Cloud service use GooglePlayConnection.CLIENT_APPSTATE
//if you want both: GooglePlayConnection.CLIENT_GAMES | GooglePlayConnection.CLIENT_APPSTATE
//and if you whant to get avaliable permissions for your app use: GooglePlayConnection.CLIENT_ALL
GooglePlayConnection.instance.start (GooglePlayConnection.CLIENT_GAMES | GooglePlayConnection.CLIENT_APPSTATE );