在不工作的谷歌Android标志?

问题描述 投票:6回答:3

所以,我的项目遇到的一个问题是,通过谷歌在符号不工作始终。即,它适合我的朋友,而不是我从我的电脑,即使它昨天为我擦我的手机之前(电话被损坏)。我们的登录密码是谷歌标准的登录,问题是这个结果保持返回false,我想。编码:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome_screen);
        findViewById(R.id.sign_in_button).setOnClickListener(this);

        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build();

        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .build();

        SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button);
        signInButton.setSize(SignInButton.SIZE_STANDARD);
        signInButton.setScopes(gso.getScopeArray());

    }

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

private void signIn() {
        Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
        startActivityForResult(signInIntent, RC_SIGN_IN);
    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
        if (requestCode == RC_SIGN_IN) {
            GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
            handleSignInResult(result);
        }
    }

    private void handleSignInResult(GoogleSignInResult result) {
        if (result.isSuccess()) {
            // Signed in successfully, show authenticated UI.
            GoogleSignInAccount acct = result.getSignInAccount();

//            mStatusTextView.setText(getString(R.string.signed_in_fmt, acct.getDisplayName()));
            updateUI(acct);
        } else {
            // Signed out, show unauthenticated UI.
            noUpdateUI();
        }
    }

    private void updateUI(GoogleSignInAccount acct) {
        Intent intent = new Intent(getApplicationContext(), HomeScreen.class);

        Bundle bundle = new Bundle();
        bundle.putSerializable("NEW_USER", new ClientUser(acct));
        intent.putExtras(bundle);

        startActivity(intent);
    }


For some reason, the result is false:

    private void noUpdateUI() {
        System.out.println("**** Try again****");
//        mStatusTextView.setText(R.string.signed_out);
        findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
    }

我想我已经正确设置了我的应用程序的凭据,因为它从我的桌面曾任职之前我擦我的电话。值得注意的是,我的朋友有同样的问题,从他的笔记本电脑,但并没有从他的桌面工作的问题。不知道这是怎么回事;有什么建议么?

从sys.out日志:

12-16 18:48:43.282 27375-27375/oose2017.place2b D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
12-16 18:48:43.412 27375-27375/oose2017.place2b I/Timeline: Timeline: Activity_launch_request id:oose2017.place2b time:3231784
12-16 18:48:43.452 27375-27375/oose2017.place2b D/Activity: performCreate Call Injection manager
12-16 18:48:43.462 27375-27375/oose2017.place2b I/InjectionManager: dispatchOnViewCreated > Target : com.google.android.gms.auth.api.signin.internal.SignInHubActivity isFragment :false
12-16 18:48:43.462 27375-27375/oose2017.place2b D/PhoneWindow: *FMB* installDecor mIsFloating : false
12-16 18:48:43.462 27375-27375/oose2017.place2b D/PhoneWindow: *FMB* installDecor flags : 8454400
12-16 18:48:43.462 27375-27375/oose2017.place2b D/SecWifiDisplayUtil: Metadata value : SecSettings2
12-16 18:48:43.472 27375-27375/oose2017.place2b D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
12-16 18:48:43.472 27375-27375/oose2017.place2b D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
12-16 18:48:43.482 27375-27375/oose2017.place2b D/SRIB_DCS: log_dcs ThreadedRenderer::initialize entered! 
12-16 18:48:43.492 27375-27584/oose2017.place2b D/mali_winsys: new_window_surface returns 0x3000,  [1440x2560]-format:1
12-16 18:48:43.542 27375-27375/oose2017.place2b I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@174719e3 time:3231916
12-16 18:48:43.962 27375-27375/oose2017.place2b V/ActivityThread: updateVisibility : ActivityRecord{1458bd29 token=android.os.BinderProxy@e9978a8 {oose2017.place2b/oose2017.place2b.interfaces.Welcome.WelcomeScreen}} show : true
12-16 18:48:43.962 27375-27375/oose2017.place2b V/ActivityThread: updateVisibility : ActivityRecord{d3e4299 token=android.os.BinderProxy@174719e3 {oose2017.place2b/com.google.android.gms.auth.api.signin.internal.SignInHubActivity}} show : true
12-16 18:48:48.102 27375-27375/oose2017.place2b I/System.out: ***** Try again!*****
12-16 18:48:48.132 27375-27375/oose2017.place2b I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@e9978a8 time:3236507
android google-signin google-plus-signin
3个回答
8
投票

我有同样的问题。我解决它通过执行以下操作:

  1. 我去了我的build.gradle(APP),里面defaultConfig和改变的applicationID我的包的名字(我不知道为什么它不是同最初)。我从compile 'com.google.android.gms:play-services-auth:8.3.0'compile 'com.google.android.gms:play-services-auth:8.4.0'确保apply plugin: 'com.google.gms.google-services'是您的build.gradle(APP)的底部,即切换后的依赖性
  2. 我产生了新的SHA-1键。为了产生SHA-1键粘贴此在你的终端:keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android然后去你credentials page并选择您的项目。
  3. 下的OAuth 2.0客户端,点击您的Android客户端密钥。粘贴您所产生的SHA-1密钥和包名遵医嘱。点击保存。 下载新的谷歌,services.json文件,并将其粘贴到您的应用程序/目录。

然后尝试再次登录。希望它应该工作。欲了解更多信息,请参阅本postthis as well。它帮我解决我的


0
投票

您需要附上您的Android客户端密钥生成这样GoogleSignInOptions时

  signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).
            requestScopes(new Scope(Scopes.EMAIL)).
            requestEmail().
            requestIdToken(getString(R.string.client_id)).
            build();

0
投票

我不得不降级从游戏服务-auth的16.0.0至

implementation 'com.google.android.gms:play-services-auth:15.0.1'

然后它的工作。

© www.soinside.com 2019 - 2024. All rights reserved.