[英]flutter google sign in not working in release when downloading from play store
我的 flutter 应用程序中的谷歌登录在 iOS 和 android 模拟器中以及从应用商店下载时处于发布模式的 iOS 中都能完美运行。 问题是来自 Play 商店的发布 appbundle 不起作用。 当我点击谷歌登录按钮时,它会显示我的帐户,我输入 select 帐户,它会闪烁并返回主屏幕。
我运行了 ./gradlew signingReport 并获得了调试和发布 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'
}
}
这是我的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
}
要在没有 firebase 的情况下实施,请尝试签证 - https://github.com/e-oj/visa
这是 Facebook 身份验证的示例(它还支持谷歌):
import 'package:visa/auth-data.dart';
import 'package:visa/fb.dart';
class AuthPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
/// Simply Provide all the necessary credentials
body: FaceBookAuth().visa.authenticate(
clientID: '139732240983759',
redirectUri: 'https://www.e-oj.com/oauth',
scope: 'public_profile,email',
state: 'fbAuth',
onDone: done
)
);
}
}
和“完成”回调:
done(AuthData authData){
print(authData);
/// You can pass the [AuthData] object to a
/// post-authentication screen. It contaions
/// all the user and OAuth data collected during
/// the authentication process. In this example,
/// our post-authentication screen is "complete-profile".
Navigator.pushReplacementNamed(
context, '/complete-profile', arguments: authData
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.