无法实施Google Play排行榜

时间:2014-07-23 04:37:47

标签: android google-play

我正在关注https://developers.google.com/games/services/android/leaderboards的指南 我添加了BaseGameUtilsgoogle-play-services-lib

library

package com.surreall.matchit;

import com.google.android.gms.games.Games;
import com.google.example.games.basegameutils.BaseGameActivity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Start extends BaseGameActivity{

    protected static final String REQUEST_LEADERBOARD = null;

    Button leader;
    OnClickListener leaderListener;

    String LEADERBOARD_ID = "CgkxxxxxxxQBQ";
     @Override
        public void onCreate(Bundle savedInstanceState) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 
            super.onCreate(savedInstanceState);
            setContentView(R.layout.startpage);

            leader = (Button)findViewById(R.id.leaderboard);
            leaderListener = new OnClickListener(){

                @Override
                public void onClick(View v) { 

                    startActivityForResult(Games.Leaderboards.getLeaderboardIntent(getApiClient(),  LEADERBOARD_ID), REQUEST_LEADERBOARD);


                }

            };

            leader.setOnClickListener(leaderListener);
     }
    protected void startActivityForResult(Intent leaderboardIntent,
            String requestLeaderboard) {
        // TODO Auto-generated method stub

    }
    @Override
    public void onSignInFailed() {
        // TODO Auto-generated method stub

    }
    @Override
    public void onSignInSucceeded() {
        // TODO Auto-generated method stub

    }


}

清单文件:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.surreall.matchit"
  android:versionCode="1"
  android:versionName="1"
  android:installLocation="auto"
  android:resizeable="true">

   <uses-sdk 
        android:minSdkVersion="9" 
        android:targetSdkVersion="19"/>

  <application 
      android:icon="@drawable/icon" 
      android:label="@string/app_name" 
      android:theme="@android:style/Theme.NoTitleBar"
      android:name="com.surreall.matchit.MyApplication">

        <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"/>


         <activity android:name=".Start" android:label="Start">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

</application>

我试图打电话时:

startActivityForResult(Games.Leaderboards.getLeaderboardIntent(getApiClient(), LEADERBOARD_ID), REQUEST_LEADERBOARD);

我得到一个力量关闭:

07-22 20:23:28.895: I/Process(21399): Sending signal. PID: 21399 SIG: 9
07-22 20:36:47.200: I/dalvikvm(21801): Could not find method android.support.v4.app.FragmentManager.getFragments, referenced from method com.google.android.gms.common.api.GoogleApiClient$Builder.eE
07-22 20:36:47.200: W/dalvikvm(21801): VFY: unable to resolve virtual method 1036: Landroid/support/v4/app/FragmentManager;.getFragments ()Ljava/util/List;
07-22 20:36:47.200: D/dalvikvm(21801): VFY: replacing opcode 0x6e at 0x0006
07-22 20:36:47.200: D/dalvikvm(21801): VFY: dead code 0x0009-0047 in Lcom/google/android/gms/common/api/GoogleApiClient$Builder;.eE ()Lcom/google/android/gms/common/api/d;
07-22 20:36:47.247: I/dalvikvm(21801): Failed resolving Lcom/google/android/gms/games/internal/PopupManager$PopupManagerHCMR1; interface 499 'Landroid/view/View$OnAttachStateChangeListener;'
07-22 20:36:47.247: W/dalvikvm(21801): Link of class 'Lcom/google/android/gms/games/internal/PopupManager$PopupManagerHCMR1;' failed
07-22 20:36:47.254: E/dalvikvm(21801): Could not find class 'com.google.android.gms.games.internal.PopupManager$PopupManagerHCMR1', referenced from method com.google.android.gms.games.internal.PopupManager.a
07-22 20:36:47.254: W/dalvikvm(21801): VFY: unable to resolve new-instance 1505 (Lcom/google/android/gms/games/internal/PopupManager$PopupManagerHCMR1;) in Lcom/google/android/gms/games/internal/PopupManager;
07-22 20:36:47.254: D/dalvikvm(21801): VFY: replacing opcode 0x22 at 0x0006
07-22 20:36:47.254: D/dalvikvm(21801): VFY: dead code 0x0008-000a in Lcom/google/android/gms/games/internal/PopupManager;.a (Lcom/google/android/gms/games/internal/GamesClientImpl;I)Lcom/google/android/gms/games/internal/PopupManager;
07-22 20:36:47.332: D/dalvikvm(21801): GC_EXTERNAL_ALLOC freed 111K, 43% free 3110K/5379K, external 2357K/2773K, paused 64ms
07-22 20:36:47.911: I/dalvikvm(21801): Could not find method android.app.AlertDialog$Builder.<init>, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.a
07-22 20:36:47.911: W/dalvikvm(21801): VFY: unable to resolve direct method 64: Landroid/app/AlertDialog$Builder;.<init> (Landroid/content/Context;I)V
07-22 20:36:47.911: D/dalvikvm(21801): VFY: replacing opcode 0x70 at 0x002c
07-22 20:36:47.911: I/dalvikvm(21801): Could not find method android.app.Activity.getFragmentManager, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.b
07-22 20:36:47.911: W/dalvikvm(21801): VFY: unable to resolve virtual method 20: Landroid/app/Activity;.getFragmentManager ()Landroid/app/FragmentManager;
07-22 20:36:47.911: D/dalvikvm(21801): VFY: replacing opcode 0x6e at 0x0023
07-22 20:36:47.911: D/dalvikvm(21801): VFY: dead code 0x0026-0030 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (ILandroid/app/Activity;Landroid/support/v4/app/Fragment;ILandroid/content/DialogInterface$OnCancelListener;)Z
07-22 20:36:47.911: D/dalvikvm(21801): DexOpt: couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
07-22 20:36:47.911: W/dalvikvm(21801): VFY: unable to resolve instance field 39
07-22 20:36:47.911: D/dalvikvm(21801): VFY: replacing opcode 0x52 at 0x0012
07-22 20:36:47.911: D/dalvikvm(21801): VFY: dead code 0x0014-0018 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (Landroid/content/res/Resources;)Z
07-22 20:36:53.418: D/AndroidRuntime(21801): Shutting down VM
07-22 20:36:53.418: W/dalvikvm(21801): threadid=1: thread exiting with uncaught exception (group=0x40018560)
07-22 20:36:53.426: E/AndroidRuntime(21801): FATAL EXCEPTION: main
07-22 20:36:53.426: E/AndroidRuntime(21801): java.lang.IllegalStateException: GoogleApiClient must be connected.
07-22 20:36:53.426: E/AndroidRuntime(21801):    at com.google.android.gms.internal.hn.a(Unknown Source)
07-22 20:36:53.426: E/AndroidRuntime(21801):    at com.google.android.gms.games.Games.c(Unknown Source)
07-22 20:36:53.426: E/AndroidRuntime(21801):    at com.google.android.gms.games.internal.api.LeaderboardsImpl.getLeaderboardIntent(Unknown Source)

1 个答案:

答案 0 :(得分:0)

我的解决方案在这里找到:https://stackoverflow.com/a/20903375/486086

我的问题是我已经从Google Developer Console而不是Android Developper控制台创建了链接的应用程序...