一段时间以来一直在与andengine和google游戏服务的集成上挣扎。所以我想在这里试试运气。
我已经完成了多篇文章和博客中描述的步骤,如下所示:
Issues in integrating Google Play Game Services Leaderboard in AndEngine Game
使用android工作室和gradle
我添加了basegameutils(Android Sample),并扩展了andengine basegameactivity并重命名为googlebasegameactivity。然后我在gameactivty(main activity)中将basegameactivity替换为googlebasegameactivity
游戏在我进行扩展和重命名之前运行。
主要活动:

public class GameActivity extends GoogleBaseGameActivity

BaseGameUtils中的BaseGameActivity(谷歌):
import org.andengine.ui.activity.BaseGameActivity;

public abstract class GoogleBaseGameActivity extends BaseGameActivity implements GameHelper.GameHelperListener

日志:
03-23 10:36:15.006  15860-15860/com.tdt4240.a19.mazegame I/Process﹕ Sending signal. PID: 15860 SIG: 9
03-23 10:51:33.826  17012-17012/com.tdt4240.a19.mazegame W/dalvikvm﹕ No implementation found for native Ldalvik/system/VMRuntime;.pauseGc:(Ljava/lang/String;)I
03-23 10:51:33.826  17012-17012/com.tdt4240.a19.mazegame E/ActivityThread﹕ Pause GC
    java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at android.app.ActivityThread.pauseGC(ActivityThread.java:5410)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2277)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
            at android.app.ActivityThread.access$900(ActivityThread.java:169)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5487)
            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:1283)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.UnsatisfiedLinkError: Native method not found: dalvik.system.VMRuntime.pauseGc:(Ljava/lang/String;)I
            at dalvik.system.VMRuntime.pauseGc(Native Method)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at android.app.ActivityThread.pauseGC(ActivityThread.java:5410)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2277)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
            at android.app.ActivityThread.access$900(ActivityThread.java:169)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5487)
            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:1283)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
            at dalvik.system.NativeStart.main(Native Method)
03-23 10:51:33.831  17012-17012/com.tdt4240.a19.mazegame I/PersonaManager﹕ getPersonaService() name persona_policy
03-23 10:51:33.856  17012-17012/com.tdt4240.a19.mazegame D/MultiMazed﹕ onCreateEngineOptions() called
03-23 10:51:33.881  17012-17012/com.tdt4240.a19.mazegame I/PersonaManager﹕ getPersonaService() name persona_policy
03-23 10:51:33.896  17012-17012/com.tdt4240.a19.mazegame W/PopupManager﹕ You have not specified a View to use as content view for popups. Falling back to the Activity content view which may not work properly in future versions of the API. Use setViewForPopups() to set your content view.
03-23 10:51:33.906  17012-17012/com.tdt4240.a19.mazegame I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzg
03-23 10:51:33.906  17012-17012/com.tdt4240.a19.mazegame W/dalvikvm﹕ VFY: unable to resolve virtual method 515: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
03-23 10:51:33.906  17012-17012/com.tdt4240.a19.mazegame D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000b
03-23 10:51:33.971  17012-17012/com.tdt4240.a19.mazegame D/libEGL﹕ loaded /system/lib/egl/libEGL_mali.so
03-23 10:51:33.976  17012-17012/com.tdt4240.a19.mazegame D/libEGL﹕ loaded /system/lib/egl/libGLESv1_CM_mali.so
03-23 10:51:33.981  17012-17012/com.tdt4240.a19.mazegame D/libEGL﹕ loaded /system/lib/egl/libGLESv2_mali.so
03-23 10:51:33.981  17012-17012/com.tdt4240.a19.mazegame E/﹕ Device driver API match
    Device driver API version: 23
    User space API version: 23
03-23 10:51:33.981  17012-17012/com.tdt4240.a19.mazegame E/﹕ mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Mon Feb 10 15:44:10 KST 2014
03-23 10:51:34.036  17012-17012/com.tdt4240.a19.mazegame D/OpenGLRenderer﹕ Enabling debug mode 0
03-23 10:51:34.141  17012-17026/com.tdt4240.a19.mazegame D/MultiMazed﹕ onPopulateScene() called
03-23 10:51:34.141  17012-17026/com.tdt4240.a19.mazegame D/MultiMazed﹕ onCreateScene() called
03-23 10:51:34.141  17012-17026/com.tdt4240.a19.mazegame D/MultiMazed﹕ onCreateResources() called
03-23 10:51:34.336  17012-17012/com.tdt4240.a19.mazegame D/AndroidRuntime﹕ Shutting down VM
03-23 10:51:34.336  17012-17012/com.tdt4240.a19.mazegame W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41d0dc08)
03-23 10:51:34.336  17012-17012/com.tdt4240.a19.mazegame E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.tdt4240.a19.mazegame, PID: 17012
    java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
            at com.google.android.gms.common.internal.zzk$zza.zzc(Unknown Source)
            at com.google.android.gms.common.internal.zzk$zza.zzi(Unknown Source)
            at com.google.android.gms.common.internal.zzk$zzc.zzjg(Unknown Source)
            at com.google.android.gms.common.internal.zzk$zzb.handleMessage(Unknown Source)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5487)
            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:1283)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
            at dalvik.system.NativeStart.main(Native Method)
03-23 10:51:34.416  17012-17026/com.tdt4240.a19.mazegame D/dalvikvm﹕ GC_EXPLICIT freed 1537K, 32% free 5498K/8056K, paused 3ms+8ms, total 74ms
03-23 10:51:34.481  17012-17026/com.tdt4240.a19.mazegame D/dalvikvm﹕ GC_EXPLICIT freed 40K, 32% free 5494K/8056K, paused 6ms+3ms, total 50ms
03-23 10:56:34.371  17012-17012/com.tdt4240.a19.mazegame I/Process﹕ Sending signal. PID: 17012 SIG: 9

最佳答案

当应用程序ID不正确或位于错误的位置时会发生这种情况。对我来说,我不得不改变我的清单:

<meta-data android:name="com.google.android.gms.games.APP_ID"
        android:value="000000000000" />
    <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version"/>

string.xml文件中实际引用它。所以它变成了:
<meta-data android:name="com.google.android.gms.games.APP_ID"
        android:value="@string/app_id" />
    <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version"/>

然后我把我的应用程序id放在strings类中。我不知道为什么会这样,但这就是我解决问题的原因。

10-08 11:22