3

Project have just this code, and I just follow this description. Visit https://developers.google.com/games/services/android/init

Make Project and adding library 'google-play-services_lib' and 'BaseGameUtiles'

Change 'extends Activity' to 'BaseGameActivity' and add some code.

I build and run... my app is crashed with Java.lang.illegal

How can i fix this?

public class MainActivity extends BaseGameActivity implements View.OnClickListener{

    Button btnLogin;
    ImageView profilePic;
    TextView profileName;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            btnLogin = (Button)findViewById(R.id.btn_login);
            profilePic = (ImageView)findViewById(R.id.img_userprofile);
            profileName = (TextView)findViewById(R.id.txt_user_name);

            btnLogin.setOnClickListener(this);
    }


    @Override
    public void onSignInFailed() {
            profileName.setText("LOGIN FAILED");
    }

    @Override
    public void onSignInSucceeded() {
            profileName.setText("LOGIN SUCCESS");
    }

    @Override
    public void onClick(View v) {
            switch(v.getId())
            {
            case R.id.btn_login:
                    beginUserInitiatedSignIn();
                    break;
            }
    }

}

Error logs:

09-15 11:06:09.420: I/dalvikvm(1753): Could not find method android.view.View.getDisplay, referenced from method com.google.android.gms.internal.bv$b.b
09-15 11:06:09.420: W/dalvikvm(1753): VFY: unable to resolve virtual method 3183: Landroid/view/View;.getDisplay ()Landroid/view/Display;
09-15 11:06:09.420: D/dalvikvm(1753): VFY: replacing opcode 0x6e at 0x0009
09-15 11:06:09.505: W/PopupManager(1753): 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.
09-15 11:06:09.635: D/libEGL(1753): loaded /system/lib/egl/libEGL_mali.so
09-15 11:06:09.650: D/libEGL(1753): loaded /system/lib/egl/libGLESv1_CM_mali.so
09-15 11:06:09.655: D/libEGL(1753): loaded /system/lib/egl/libGLESv2_mali.so
09-15 11:06:09.660: D/(1753): Device driver API match
09-15 11:06:09.660: D/(1753): Device driver API version: 10
09-15 11:06:09.660: D/(1753): User space API version: 10 
09-15 11:06:09.660: D/(1753): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Fri Oct 12 13:25:41 KST 2012 
09-15 11:06:09.710: D/OpenGLRenderer(1753): Enabling debug mode 0
09-15 11:06:10.080: D/AndroidRuntime(1753): Shutting down VM
09-15 11:06:10.080: W/dalvikvm(1753): threadid=1: thread exiting with uncaught exception (group=0x418412a0)
09-15 11:06:10.095: E/AndroidRuntime(1753): FATAL EXCEPTION: main
09-15 11:06:10.095: E/AndroidRuntime(1753): java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
09-15 11:06:10.095: E/AndroidRuntime(1753):     at com.google.android.gms.internal.u$f.a(Unknown Source)
09-15 11:06:10.095: E/AndroidRuntime(1753):     at com.google.android.gms.internal.u$f.a(Unknown Source)
09-15 11:06:10.095: E/AndroidRuntime(1753):     at com.google.android.gms.internal.u$b.A(Unknown Source)
09-15 11:06:10.095: E/AndroidRuntime(1753):     at com.google.android.gms.internal.u$a.handleMessage(Unknown Source)
09-15 11:06:10.095: E/AndroidRuntime(1753):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-15 11:06:10.095: E/AndroidRuntime(1753):     at android.os.Looper.loop(Looper.java:137)
09-15 11:06:10.095: E/AndroidRuntime(1753):     at android.app.ActivityThread.main(ActivityThread.java:4946)
09-15 11:06:10.095: E/AndroidRuntime(1753):     at java.lang.reflect.Method.invokeNative(Native Method)
09-15 11:06:10.095: E/AndroidRuntime(1753):     at java.lang.reflect.Method.invoke(Method.java:511)
09-15 11:06:10.095: E/AndroidRuntime(1753):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1036)
09-15 11:06:10.095: E/AndroidRuntime(1753):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:803)
09-15 11:06:10.095: E/AndroidRuntime(1753):     at dalvik.system.NativeStart.main(Native Method)
jbihan
  • 3,053
  • 2
  • 24
  • 34
Sizzling
  • 215
  • 1
  • 3
  • 7

1 Answers1

6

It seems like you forget to add APP_ID metadata in your manifest file. You need to add the following code exactly inside the tag in the Android Manifest file:

<meta-data android:name="com.google.android.gms.games.APP_ID"
    android:value="@string/app_id" />

Please make sure the meta tag is not inside the tag but tag, and use APP_ID which is 12 digits number placed right of your game title in your play game console.

for more info, check below link: https://developers.google.com/games/services/android/quickstart#step_3_modify_your_code

Chansuk
  • 792
  • 4
  • 7