我已经成功地将 Play Games 用于成就和排行榜,现在我正在尝试实现多人系统(我已在开发者控制台中启用它)。
如此处所述,此代码应启动快速游戏活动:
if (getGamesClient().isConnected()) {
Bundle am = RoomConfig.createAutoMatchCriteria(1, 1, 0);
RoomConfig.Builder roomConfigBuilder = makeBasicRoomConfigBuilder();
roomConfigBuilder.setAutoMatchCriteria(am);
RoomConfig roomConfig = roomConfigBuilder.build();
getGamesClient().createRoom(roomConfig);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
它实际上适用于我的 Nexus 7,但不适用于我的 Galaxy S4。未调用 onRoomCreated 事件,我得到一个 ARM 我唯一的提示是 logcat 中的这些行:
07-06 14:15:46.221: E/AndroidRuntime(22967): FATAL EXCEPTION: main
07-06 14:15:46.221: E/AndroidRuntime(22967): java.lang.ExceptionInInitializerError
07-06 14:15:46.221: E/AndroidRuntime(22967): at ajd.<init>(SourceFile:361)
07-06 14:15:46.221: E/AndroidRuntime(22967): at ajd.a(SourceFile:476)
07-06 14:15:46.221: E/AndroidRuntime(22967): at ara.<init>(SourceFile:120)
07-06 14:15:46.221: E/AndroidRuntime(22967): at com.google.android.gms.games.service.RealTimeMatchAndroidService.onBind(SourceFile:73)
07-06 14:15:46.221: E/AndroidRuntime(22967): at android.app.ActivityThread.handleBindService(ActivityThread.java:2647)
07-06 14:15:46.221: E/AndroidRuntime(22967): at android.app.ActivityThread.access$1800(ActivityThread.java:152)
07-06 14:15:46.221: E/AndroidRuntime(22967): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)
07-06 14:15:46.221: E/AndroidRuntime(22967): at android.os.Handler.dispatchMessage(Handler.java:99)
07-06 14:15:46.221: E/AndroidRuntime(22967): at android.os.Looper.loop(Looper.java:137)
07-06 14:15:46.221: E/AndroidRuntime(22967): at android.app.ActivityThread.main(ActivityThread.java:5328)
07-06 14:15:46.221: E/AndroidRuntime(22967): at java.lang.reflect.Method.invokeNative(Native Method)
07-06 14:15:46.221: E/AndroidRuntime(22967): at java.lang.reflect.Method.invoke(Method.java:511)
07-06 14:15:46.221: E/AndroidRuntime(22967): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
07-06 14:15:46.221: E/AndroidRuntime(22967): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
07-06 14:15:46.221: E/AndroidRuntime(22967): at dalvik.system.NativeStart.main(Native Method)
07-06 14:15:46.221: E/AndroidRuntime(22967): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load games_rtmp_jni from loader dalvik.system.PathClassLoader[dexPath=/system/framework/com.android.location.provider.jar:/system/app/GmsCore.apk,libraryPath=/data/app-lib/com.google.android.gms-1]: findLibrary returned null
07-06 14:15:46.221: E/AndroidRuntime(22967): at java.lang.Runtime.loadLibrary(Runtime.java:365)
07-06 14:15:46.221: E/AndroidRuntime(22967): at java.lang.System.loadLibrary(System.java:535)
07-06 14:15:46.221: E/AndroidRuntime(22967): at com.google.android.gms.games.jingle.Libjingle.<clinit>(SourceFile:38)
07-06 14:15:46.221: E/AndroidRuntime(22967): ... 15 more
更新:我不再有问题。我备份了我的手机,安装了另一个 ROM(它正在工作,所以我开发了它),然后重新安装了他的备份,它开始工作了。同时撤销了我的 Google+ 帐户和我的应用程序之间的连接(google+ 应用程序 -> 设置 -> Google+ 登录)。所以我不知道哪一个真正解决了我的问题。