从 Play 商店下载时,flutter google 登录无法在发布中工作

RNA*_*RNA 2 android google-signin flutter

我的 google 登录我的 flutter 应用程序在 iOS 和 android 模拟器中都可以完美运行,并且在从应用商店下载时在 iOS 中处于发布模式。问题是来自 Play 商店的发布 appbundle 不起作用。当我点击 google 登录按钮时,它会显示我的帐户,我选择了该帐户,它通过并闪烁并返回主屏幕。

我已经运行了 ./gradlew signatureReport 并获得了调试和发布 SHA1 密钥并将它们放置在我的 firebase 控制台中。

我的应用程序级 build.grade 看起来像这样

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

   def keystoreProperties = new Properties()
   def keystorePropertiesFile = rootProject.file('key.properties')
   if (keystorePropertiesFile.exists()) {
       keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
   }



android {
    compileSdkVersion 29

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.rnainc.edganizer_school_app"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        
        multiDexEnabled true
        //ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
    }

   signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            aaptOptions { cruncherEnabled = false }
            
            // need either some or all of the following 4 lines to make sure the app actually launches when downloaded from the play store, otherwise it crashes upon installation
            minifyEnabled false
            useProguard false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.android.support:multidex:1.0.3'
}

apply plugin: 'com.google.gms.google-services'

 configurations.all {
    resolutionStrategy {
        force 'com.google.android.gms:play-services-location:15.0.0'
     }
 }
Run Code Online (Sandbox Code Playgroud)

这是我的 android 级别 build.grade,如您所见,我尝试了多个版本,3.6.4、4.0.1、4.1.0,都是同样的问题。我尝试了其他的事情,比如更新到所有 firebase 插件的最新版本,flutter clean。但还是同样的问题。我还在我的 GCP 控制台中检查了 GCP OAuth 2.0 客户端 ID,它显示了为我制作的两个证书(当我将 SHA1 密钥添加到 firebase 时自动生成)。

我真的不确定我还能做些什么来使这个工作正常进行,老实说,不确定问题出在哪里。

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        //classpath 'com.android.tools.build:gradle:4.0.1'
        //classpath 'com.android.tools.build:gradle:4.1.0'
        classpath 'com.android.tools.build:gradle:3.6.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.4'
        
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

小智 5

您需要复制在播放控制台中生成的新 SHA-1 并将其添加到 firebase / GCP

播放控制台 - 应用签名