基本上我有一个游戏应用程序,我正在尝试实现一个排行榜,我正在关注这个教程http://code.tutsplus.com/tutorials/google-play-game-services-leaderboards--cms-20700到目前为止我试图允许该应用程序登录谷歌播放,但当我运行我的应用程序当前在启动时崩溃了,我在我的logcat中得到了这个:
这是我的代码:
public class Mainmenu extends BaseGameActivity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
findViewById(R.id.sign_in_button).setOnClickListener(this);
findViewById(R.id.sign_out_button).setOnClickListener(this);
final Button click=(Button)findViewById(R.id.button1); // Button to game
click.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
Intent launchactivity= new Intent(Mainmenu.this,Game.class);
startActivity(launchactivity);
}
});
String file = "highscore";
try{
FileInputStream fin = openFileInput(file);
int c;
String temp="";
while( (c = fin.read()) != -1){
temp = temp + Character.toString((char)c);
}
TextView textview = (TextView)findViewById(R.id.textView1);
textview.setText("Highscore: " + temp);
}catch(Exception e){
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.mainmenu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onSignInFailed() {
// TODO Auto-generated method stub
findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
findViewById(R.id.sign_out_button).setVisibility(View.GONE);
}
@Override
public void onSignInSucceeded() {
// TODO Auto-generated method stub
findViewById(R.id.sign_in_button).setVisibility(View.GONE);
findViewById(R.id.sign_out_button).setVisibility(View.VISIBLE);
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.sign_in_button) {
beginUserInitiatedSignIn();
}
else if (view.getId() == R.id.sign_out_button) {
signOut();
findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
findViewById(R.id.sign_out_button).setVisibility(View.GONE);
}
}
}
11-28 20:43:00.844: D/AndroidRuntime(25539): --------- beginning of crash
11-28 20:43:00.844: E/AndroidRuntime(25539): FATAL EXCEPTION: main
11-28 20:43:00.844: E/AndroidRuntime(25539): Process: com.jreece.flashytiles, PID: 25539
11-28 20:43:00.844: E/AndroidRuntime(25539): java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
11-28 20:43:00.844: E/AndroidRuntime(25539): at com.google.android.gms.common.internal.e$h.b(Unknown Source)
11-28 20:43:00.844: E/AndroidRuntime(25539): at com.google.android.gms.common.internal.e$h.g(Unknown Source)
11-28 20:43:00.844: E/AndroidRuntime(25539): at com.google.android.gms.common.internal.e$b.gU(Unknown Source)
11-28 20:43:00.844: E/AndroidRuntime(25539): at com.google.android.gms.common.internal.e$a.handleMessage(Unknown Source)
11-28 20:43:00.844: E/AndroidRuntime(25539): at android.os.Handler.dispatchMessage(Handler.java:102)
11-28 20:43:00.844: E/AndroidRuntime(25539): at android.os.Looper.loop(Looper.java:135)
11-28 20:43:00.844: E/AndroidRuntime(25539): at android.app.ActivityThread.main(ActivityThread.java:5221)
11-28 20:43:00.844: E/AndroidRuntime(25539): at java.lang.reflect.Method.invoke(Native Method)
11-28 20:43:00.844: E/AndroidRuntime(25539): at java.lang.reflect.Method.invoke(Method.java:372)
11-28 20:43:00.844: E/AndroidRuntime(25539): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
11-28 20:43:00.844: E/AndroidRuntime(25539): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)