所以我试图与朋友一起制作多人游戏。对于多人游戏部分,我将项目连接到开发者控制台并复制了Google(经典按钮点击器)提供的一些示例代码,以查看编码的工作原理。问题是,当我运行它并向某人发送邀请时,它不起作用。邀请显示在另一台设备上但是当它接受时,该项目仅适用于一部手机并停止工作。我使用的是实际设备,而不是模拟器。这是原木猫。
$formulaire=$this->createForm(new ProjetType(), $nouveauProjet, array(
'validation_groups' => array('Default', 'creation'),
));
奇怪的是,当我尝试从其他设备发送邀请时,它连接两个设备并开始游戏。在游戏中,你应该能够看到你的分数和其他玩家得分,但是,你只能在一台设备上看到两个分数,而在另一台设备上,你只能看到自己的分数。这里是logcat。
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=10002, result=-1, data=Intent { (has extras) }} to activity {ml.digits/ml.digits.MultiPlayerSignIn}: java.lang.IllegalStateException: Room ID must not be null or empty
at android.app.ActivityThread.deliverResults(ActivityThread.java:4058)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4101)
at android.app.ActivityThread.access$1400(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1497)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.IllegalStateException: Room ID must not be null or empty
at android.os.Parcel.readException(Parcel.java:1548)
at android.os.Parcel.readException(Parcel.java:1493)
at com.google.android.gms.games.internal.IGamesService$Stub$Proxy.zzb(Unknown Source)
at com.google.android.gms.games.internal.GamesClientImpl.zza(Unknown Source)
at com.google.android.gms.games.internal.api.RealTimeMultiplayerImpl.sendUnreliableMessage(Unknown Source)
at ml.digits.MultiPlayerSignIn.broadcastScore(MultiPlayerSignIn.java:760)
at ml.digits.MultiPlayerSignIn.startGame(MultiPlayerSignIn.java:638)
at ml.digits.MultiPlayerSignIn.onActivityResult(MultiPlayerSignIn.java:229)
at android.app.Activity.dispatchActivityResult(Activity.java:6549)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4054)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4101)
at android.app.ActivityThread.access$1400(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1497)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
最后但并非最不重要的,这里是MultiPlayerSignIn.class中抛出错误的方法的代码。
E/Parcel﹕ Class not found when unmarshalling: com.google.android.gms.games.multiplayer.realtime.RoomEntity
java.lang.ClassNotFoundException: com.google.android.gms.games.multiplayer.realtime.RoomEntity
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:308)
at java.lang.Class.forName(Class.java:272)
at android.os.Parcel.readParcelableCreator(Parcel.java:2275)
at android.os.Parcel.readParcelable(Parcel.java:2239)
at android.os.Parcel.readValue(Parcel.java:2146)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2479)
at android.os.BaseBundle.unparcel(BaseBundle.java:221)
at android.os.BaseBundle.getString(BaseBundle.java:918)
at android.content.Intent.getStringExtra(Intent.java:5386)
at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1811)
at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1364)
at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:4727)
at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:4572)
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:140)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3093)
at android.os.Binder.execTransact(Binder.java:446)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.games.multiplayer.realtime.RoomEntity" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:308)
at java.lang.Class.forName(Class.java:272)
at android.os.Parcel.readParcelableCreator(Parcel.java:2275)
at android.os.Parcel.readParcelable(Parcel.java:2239)
at android.os.Parcel.readValue(Parcel.java:2146)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2479)
at android.os.BaseBundle.unparcel(BaseBundle.java:221)
at android.os.BaseBundle.getString(BaseBundle.java:918)
at android.content.Intent.getStringExtra(Intent.java:5386)
at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1811)
at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1364)
at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:4727)
at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:4572)
at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:140)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3093)
at android.os.Binder.execTransact(Binder.java:446)
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.games.multiplayer.realtime.RoomEntity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 18 more
这里是创建房间的地方。它不应该是
时为空 if (finalScore) {
Log.d(TAG, "This is the room"+mRoomId);
// final score notification must be sent via reliable message
Games.RealTimeMultiplayer.sendReliableMessage(mGoogleApiClient, null, mMsgBuf,
mRoomId, p.getParticipantId());
} else {
// it's an interim score notification, so we can use unreliable
Games.RealTimeMultiplayer.sendUnreliableMessage(mGoogleApiClient, mMsgBuf, mRoomId,
p.getParticipantId());
}
感谢您提供任何帮助(:Here's,我从中获取了代码。
答案 0 :(得分:2)
尝试在mRoomId = room.getRoomId()
- 方法:
onJoinedRoom
public void onJoinedRoom(int statusCode, Room room) {
...
mRoomId = room.getRoomId();
...
}
答案 1 :(得分:0)
Google的示例代码也会发生这种情况。 我在三星设备上看到了它。 你也在三星Note吗?
Google工程师声称它对功能没有影响:
https://github.com/playgameservices/cpp-android-basic-samples/issues/17