我在游戏中设置了Google Play游戏服务,但没有任何反应

时间:2015-04-08 04:55:16

标签: android actionscript-3 air google-play-games ane

我正在 Android Adob​​e Air 游戏中启用 Google Play游戏。有2个应用程序是完整的和演示的。但对于这两个应用程序来说,看起来只会忽略SignIn / SubmitScore / ReportAchievement代码。

我正在使用this ANE,但也尝试了this并且它是原始的分叉。对于所有结果是相同的。代码“被忽略”,没有任何反应。

我的项目设置:

  • 所有项目都在FlashDevelop中完成,编译和打包。平台是Air Mobile 14.0,SDK是Adobe Air 16.0。我使用自己的.p12证书购买Android软件包,每个App版本一个。
  • 我在FlashDevelop上包含ANE的方式与我在Game Center中的方式相同 ANE,对于同一个APP。游戏中心正在运作,所以我想 这个也应该没事。
  • 我已将com.google.android.gms.games.APP_ID添加到xml,以及ANE要求的添加内容。

在我的代码中我做了(没有任何反应,没有调用回调函数,没有触发信号,弹出屏幕没有登录,但是显示了我的“跟踪”通知,因此代码已经到达):

Games.initialize();
addListeners(); //Adding SignIn and SignOut callbacks

Games.promptUserToSignInOnStartup(true);
Games.start();
NotificationSystem.notifyLoading("Connecting to Google Play Games Service");

在Google的开发者控制台上:

  • 这两个应用程序都是针对Alpha / Beta测试发布的,还没有生产版本。
  • 我已经设置了Play游戏服务,它已经“准备好测试”了。
  • 这两个应用已与其关联并获得授权。我为.p12验证了OAuth2.0 SHA1指纹,它们匹配。

这是我的APK的AndroidManifest.xml,因为我无法想象代码端或Google的控制台方面的问题..我认为在打包时它应该在ANE的配置上。所以它可能在这里:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="air.mygame">
<application android:hardwareAccelerated="false" android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:configChanges="keyboardHidden|orientation|screenSize" android:label="@string/app_name" android:launchMode="singleTask" android:name=".AppEntry" android:screenOrientation="user" android:theme="@style/Theme.NoShadow" android:windowSoftInputMode="adjustResize|stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <meta-data android:name="namespaceVersion" android:value="14.0"/>
        <meta-data android:name="aspectRatio" android:value="portrait"/>
        <meta-data android:name="autoOrients" android:value="true"/>
        <meta-data android:name="fullScreen" android:value="true"/>
        <meta-data android:name="uniqueappversionid" android:value="251bf45a-b5b6-49ae-bb1a-4337f47f8f34"/>
        <meta-data android:name="initialcontent" android:value="mygame.swf"/>
        <meta-data android:name="containsVideo" android:value="false"/>
    </activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="MY_APP_ID_ON_GOOGLE_PLAY_GAMES"/>
<meta-data android:name="com.google.android.gms.version" android:value="4242000"/>
<activity android:name="com.google.api.games.SignInActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
<activity android:name="com.google.api.games.StubActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
</manifest>

1 个答案:

答案 0 :(得分:1)

确定!我发现了错误,确实在AndroidManifest.xml中。

对于其他正在努力解决这个问题的人来说,问题是当使用Adobe Air时我们不直接编辑AndroidManifest.xml文件,我们使用manifestAdditions标签编辑application.xml。并且需要的补充进入了错误的地方。

我的application.xml就像:

<android>
   <manifestAdditions>
      <![CDATA[<manifest android:installLocation="auto">
         <uses-permission android:name="android.permission.INTERNET" />
         <uses-permission android:name="android.permission.WAKE_LOCK" />
         <uses-sdk android:minSdkVersion="9" />
         <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
         <!-- GooglePlay Games Services -->
         <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ MY_GOOGLE_PLAY_GAMES_APP_ID" />
         <meta-data android:name="com.google.android.gms.version" android:value="4242000" />
         <activity android:name="com.google.api.games.SignInActivity" 
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
         <activity android:name="com.google.api.games.StubActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
      </manifest>]]>
   </manifestAdditions>
</android>

查看Google's guide最终AndroidManifest.xml上的应用程序标记之外可能没有活动标记。此外,根据this,元数据标记也应该位于应用程序标记内。

我只需要编辑application.xml,看起来像:

<android>
   <manifestAdditions>
      <![CDATA[<manifest android:installLocation="auto">
         <uses-permission android:name="android.permission.INTERNET" />
         <uses-permission android:name="android.permission.WAKE_LOCK" />
         <uses-sdk android:minSdkVersion="9" />
         <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
         <!-- GooglePlay Games Services -->
         <application> <!-- This will be merged with application tag in the final manifest file -->
            <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ MY_GOOGLE_PLAY_GAMES_APP_ID" />
            <meta-data android:name="com.google.android.gms.version" android:value="4242000" />
            <activity android:name="com.google.api.games.SignInActivity" 
               android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
            <activity android:name="com.google.api.games.StubActivity"
               android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
         </application>
      </manifest>]]>
   </manifestAdditions>
</android>

要打开最终的AndroidManifest.xml文件进行检查,可以使用apktool。