Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter google sign in not working in release when downloading from play store

my google sign in my flutter app works perfectly in both iOS and android simulators, and in iOS in release mode when downloading from app store. The problem is the release appbundle from the play store doesn't work. when I click the google sign in button, it shows my accounts, I select the account, it goes through and just flickers and goes back to the main screen.

I have run ./gradlew signingReport and have gotten both debug and release SHA1 Keys and placed them in my firebase console.

my app level build.grade looks like this

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'
     }
 }

this is my android level build.grade, as you can see, I tried multiple versions, 3.6.4, 4.0.1, 4.1.0, all the same problem. I have tried other things like updating to the latest versions of all firebase plugins, flutter clean. But still same issue. I also checked the GCP OAuth 2.0 Client IDs in my GCP console and it shows that two certificates where made for me (auto generated when I added the SHA1 keys to firebase).

I'm really not sure what else I can tinker with to get this working, not sure where the problem is to be honest.

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
}
like image 515
RNA Avatar asked Jan 25 '23 14:01

RNA


1 Answers

You need to copy the new SHA-1 generated in play console and add it in firebase / GCP

play console - app signing

like image 108
Bharath Avatar answered Feb 12 '23 20:02

Bharath