我正在尝试实现Google Play游戏服务,我的应用程序主菜单上有一个Google+登录按钮。当用户尝试登录时,他们会通过整个登录过程(5个或更多屏幕),直到我认为它正在完成登录,然后出现以下错误。
有人能帮我吗?我不确定您需要哪些代码,但我已经发布了我
有人能帮我吗?我不确定您需要哪些代码,但我已经发布了我
MainMenu
类的相关片段。
MainMenu.class
public class MainMenu extends BaseGameActivity {
DatabaseHelper dh;
ImageView image;
Button startBtn, highscoresBtn, aboutBtn, comingsoonBtn, biblestudyBtn, signOut;
SignInButton sign_in_button;
TextView title, subtitle;
public static final String notice = "notice";
GamesClient client;
Context c;
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.mainmenu);
client = getGamesClient();
client.connect();
c = this;
sign_in_button = (SignInButton)findViewById(R.id.sign_in_button);
signOut = (Button)findViewById(R.id.sign_out_button);
startBtn = (Button)findViewById(R.id.startBtn);
highscoresBtn = (Button)findViewById(R.id.highscoresBtn);
aboutBtn = (Button)findViewById(R.id.aboutBtn);
comingsoonBtn = (Button)findViewById(R.id.comingsoonBtn);
biblestudyBtn = (Button)findViewById(R.id.biblestudyBtn);
title = (TextView)findViewById(R.id.title);
subtitle = (TextView)findViewById(R.id.subtitle);
startBtn.setText(c.getResources().getString(R.string.startBtn));
highscoresBtn.setText(c.getResources().getString(R.string.highscoresBtn));
aboutBtn.setText(c.getResources().getString(R.string.aboutBtn));
comingsoonBtn.setText(c.getResources().getString(R.string.comingsoonBtn));
biblestudyBtn.setText(c.getResources().getString(R.string.biblestudyBtn));
title.setText(c.getResources().getString(R.string.title));
subtitle.setText(c.getResources().getString(R.string.subtitle));
//sign_in_button.setText(c.getResources().getString(R.string.signin));
signOut.setText(c.getResources().getString(R.string.signout));
sign_in_button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// start the asynchronous sign-in flow
beginUserInitiatedSignIn();
}
});
signOut.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// sign-out
signOut();
// show sign-in button, hide the sign-out button
findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
findViewById(R.id.sign_out_button).setVisibility(View.GONE);
}
});
}
public void onSignInSucceeded() {
// show sign-out button, hide the sign-in button
findViewById(R.id.sign_in_button).setVisibility(View.GONE);
findViewById(R.id.sign_out_button).setVisibility(View.VISIBLE);
final Dialog dialog = new Dialog(c);
dialog.setContentView(R.layout.importlayout);
dialog.setTitle(R.string.importtitle);
TextView question = (TextView)dialog.findViewById(R.id.question);
Button save = (Button)dialog.findViewById(R.id.save);
Button scratch = (Button)dialog.findViewById(R.id.scratch);
question.setText(c.getResources().getString(R.string.importquestion));
save.setText(c.getResources().getString(R.string.savebtn));
scratch.setText(c.getResources().getString(R.string.scratchbtn));
save.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//...
}
});
scratch.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dh.deleteAll();
for(int i = 0; i < 15; i++) {
dh.insert(0, 0, "-");
}
dialog.dismiss();
dh.closeDB();
}
});
dialog.show();
}
public void onSignInFailed() {
// sign in has failed. So show the user the sign-in button.
findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
findViewById(R.id.sign_out_button).setVisibility(View.GONE);
// (add any code if needed)
}
}
编辑
我尝试过:
- 确保SHA1/证书指纹正确
编辑 #2
刚刚注意到一件事。我需要点击“发布游戏”才能让所有这些开始工作吗?
此外,我需要先将APK导出并上传到开发者控制台中吗?