gpt4 book ai didi

android - handleWindowVisibilty : no activity for the token android. os.binderproxy

转载 作者:IT王子 更新时间:2023-10-29 06:56:32 24 4
gpt4 key购买 nike

谷歌登录不工作。它给出了错误:

platformException sign_in_failed.

我确保我列出了所有依赖项和 google-services json 文件,但错误仍然存​​在。

import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:firebase_auth/firebase_auth.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Google Auth',
home: MyHomePage(),
);
}

}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();

}

class _MyHomePageState extends State<MyHomePage> {
final FirebaseAuth auth = FirebaseAuth.instance;
final GoogleSignIn googleSignIn = new GoogleSignIn();

void signin() async {
GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
GoogleSignInAuthentication gsa = await googleSignInAccount.authentication;
AuthCredential credential = await GoogleAuthProvider.getCredential(
accessToken: gsa.accessToken, idToken: gsa.idToken);
FirebaseUser user = await auth.signInWithCredential(credential);
print("signed in " + user.displayName);
}

void signout(){
googleSignIn.signOut();
print("Signed out");
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Google Auth"),
),
body: Center(
child: Column(
children: <Widget>[
new IconButton(
icon: Icon(Icons.person_add),
onPressed: ()=>signin(),
),
new IconButton(
icon: Icon(Icons.exit_to_app),
onPressed: ()=> signout(),
),
],
),
),
);
}
}

应用级渐变:

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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.google_auth"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}

flutter {
source '../..'
}

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

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

项目级gradle:

buildscript {
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
}
}

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
}

感谢任何帮助或建议

................................................ .....................................

最佳答案

首先你需要做以下事情:

1-删除与谷歌服务相关的所有依赖项。

2- 添加最新版本的 Google 服务。

3- 同步您的项目。

希望对您有所帮助。

关于android - handleWindowVisibilty : no activity for the token android. os.binderproxy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56646610/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com