GoogleSignIn停止工作 - 在onActivityResult的responseCode是0

问题描述 投票:1回答:1

我对GoogleSignin代码不工作,虽然有下列正在发生的事情没有任何错误:

  • 代码编译得到。
  • 此外,当我点击登录我得到一个弹出问我这谷歌帐户,我想与登录。
  • responseCodeonActivityResult0

这是工作精致漂亮,直到昨天,但我遇到了一些问题,同时产生签名的APK,因此升级我的Android工作室(3.3.1)的gradle改变一点点 - 现在GoogleSignin是行不通的。

花在这一天,但一直无法破解的问题。我不能很好地与Android编程熟悉并希望得到任何帮助。

相关的代码粘贴下面。在需要的情况下更多信息,请让我知道。

谢谢。

P.S: - 在signInIntentstartActivityForResultintentonActivityResult是不同的。也许这很好 - 想突出以防万一。

启动活动是:

private void signIn() {
    if(!isSignedIn()) {
        Intent signInIntent = mGoogleSignInClient.getSignInIntent();
        startActivityForResult(signInIntent, RC_SIGN_IN_ONLY_ID);
    }
}

结果活动:

   @Override
    public void onActivityResult(int requestCode, int responseCode,
                                 Intent intent) {
        super.onActivityResult(requestCode, responseCode, intent);
        switch (requestCode) {
        case RC_SIGN_IN_ONLY_ID:
            Log.d(TAG, "onActivityResult with requestCode == RC_SIGN_IN_ONLY_ID, responseCode="
                    + responseCode + ", intent=" + intent);
            mSignInClicked = false;
            mResolvingConnectionFailure = false;
           Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(intent);
            handleSignInResult(task);
            break;

该gradle这个:

    buildscript {
    repositories {
    }

    dependencies {
    }
}
apply plugin: 'com.android.application'
repositories {
//    mavenLocal()
 //   mavenCentral()
  //  google()        //---> Add this
    maven {
        url "https://maven.google.com"
    }
}

android {
    signingConfigs {
        debug {
            keyAlias 'xxx'
            keyPassword 'xxx'
            storeFile file('C:/Users/.../androidkey.jks')
            storePassword 'xxx'
        }
        config {
            keyAlias 'xxx'
            keyPassword 'xxx'
            storeFile file('C:/Users/.../androidkey.jks')
            storePassword 'xxx'
            v2SigningEnabled false
        }
    }
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.goSkill.earn"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 18
        versionName "1.0098"
        multiDexEnabled true
        signingConfig signingConfigs.config
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
            //debuggable true
            android.applicationVariants.all { variant ->
                variant.outputs.all {
                    outputFileName = "${variant.name}-${variant.versionName}.apk"
                }
            }
        }
        debug {
            signingConfig signingConfigs.debug
            minifyEnabled false
            debuggable true
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    productFlavors {
    }
}

dependencies {
    api fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    api 'com.google.android.gms:play-services:11.8.0'
    api 'com.android.support:design:27.0.0'
    api 'com.android.support:multidex:1.0.0'
}
//apply plugin: 'com.google.gms.google-services'
android android-studio-3.0
1个回答
1
投票

你建立OAuth用户端ID的项目?这就要求你创建OAuth用户端ID,并提供SHA-1密钥存储区。

谷歌签到通常Activity.RESULT_CANCELLED返回时,你没有。

按照this instruction如果你没有。

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