首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法继续使用firebase登录google;“期待活页夹,但得到了null!”

无法继续使用firebase登录google;“期待活页夹,但得到了null!”
EN

Stack Overflow用户
提问于 2022-07-08 00:52:38
回答 3查看 2.2K关注 0票数 5

我是新的移动应用程序,并使用颤振实现谷歌社交登录与firebase。我检查了官方资源并实现了如下的登录逻辑;

main.dart

代码语言:javascript
运行
复制
import 'package:atlas_app/auth/signup.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  FirebaseAuth.instance.useAuthEmulator('10.0.2.2', 9099);

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: const SignUp());
  }
}

signin.dart

代码语言:javascript
运行
复制
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_signin_button/button_list.dart';
import 'package:flutter_signin_button/button_view.dart';
import 'package:google_sign_in/google_sign_in.dart';

class SignUp extends StatefulWidget {
  const SignUp({Key? key}) : super(key: key);

  @override
  State<SignUp> createState() => _SignUpState();
}

class _SignUpState extends State<SignUp> {
  FirebaseAuth auth = FirebaseAuth.instance;

Future<UserCredential> signInWithGoogle() async {
  // Trigger the authentication flow
  final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();

  // Obtain the auth details from the request
  final GoogleSignInAuthentication? googleAuth = await googleUser?.authentication;

  // Create a new credential
  final credential = GoogleAuthProvider.credential(
    accessToken: googleAuth?.accessToken,
    idToken: googleAuth?.idToken,
  );

  // Once signed in, return the UserCredential
  return await FirebaseAuth.instance.signInWithCredential(credential);
}

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.blue,
          elevation: 8,
          title: const Text("Sign Up"),
        ),
        body: Container(
          padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 50),
          child: Form(
              child: Column(
            children: [
              SignInButton(
                Buttons.Google,
                onPressed: () async => {signInWithGoogle()},
              )
            ],
          )),
        ));
  }
}

这是如此简单,我希望工作,但当我点击登录按钮上的android模拟器(Pixel4与android 33,arm64),我的应用程序崩溃,调试控制台说;

代码语言:javascript
运行
复制
W/Parcel  (13587): Expecting binder but got null!
D/EGL_emulation(13587): app_time_stats: avg=697.35ms min=151.31ms max=1243.39ms count=2
E/JavaBinder(13587): !!! FAILED BINDER TRANSACTION !!!  (parcel size = 324)
W/GmsClient(13587): IGmsServiceBroker.getService failed
W/GmsClient(13587): android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died, but this could also be caused by running out of binder buffe
W/GmsClient(13587):     at android.os.BinderProxy.transactNative(Native Method)
W/GmsClient(13587):     at android.os.BinderProxy.transact(BinderProxy.java:584)
W/GmsClient(13587):     at com.google.android.gms.common.internal.zzac.getService(com.google.android.gms:play-services-basement@@18.0.0:8)
W/GmsClient(13587):     at com.google.android.gms.common.internal.BaseGmsClient.getRemoteService(com.google.android.gms:play-services-basement@@18.0.0:14)
W/GmsClient(13587):     at com.google.android.gms.common.api.internal.zabt.run(com.google.android.gms:play-services-base@@18.0.1:7)
W/GmsClient(13587):     at android.os.Handler.handleCallback(Handler.java:942)
W/GmsClient(13587):     at android.os.Handler.dispatchMessage(Handler.java:99)
W/GmsClient(13587):     at android.os.Looper.loopOnce(Looper.java:201)
W/GmsClient(13587):     at android.os.Looper.loop(Looper.java:288)
W/GmsClient(13587):     at android.os.HandlerThread.run(HandlerThread.java:67)
W/Parcel  (13587): Expecting binder but got null!
D/EGL_emulation(13587): eglCreateContext: 0xb400006ff0487dd0: maj 3 min 0 rcv 3
D/EGL_emulation(13587): eglCreateContext: 0xb400006ff0489e10: maj 3 min 0 rcv 3
D/HostConnection(13587): createUnique: call
D/HostConnection(13587): HostConnection::get() New Host Connection established 0xb400006ff0488f10, tid 13652
D/HostConnection(13587): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0
D/EGL_emulation(13587): eglMakeCurrent: 0xb400006ff0489e10: ver 3 0 (tinfo 0x720c8be280) (first time)
D/HostConnection(13587): createUnique: call
D/HostConnection(13587): HostConnection::get() New Host Connection established 0xb400006ff0488010, tid 13651
D/HostConnection(13587): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0
D/EGL_emulation(13587): eglMakeCurrent: 0xb400006ff0487dd0: ver 3 0 (tinfo 0x720c8be300) (first time)
D/EGL_emulation(13587): eglCreateContext: 0xb400006ff0486f90: maj 3 min 0 rcv 3
E/JavaBinder(13587): !!! FAILED BINDER TRANSACTION !!!  (parcel size = 324)
W/GmsClient(13587): IGmsServiceBroker.getService failed
W/GmsClient(13587): android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died, but this could also be caused by running out of binder buffe
......

我一直在处理这个问题,但还没有解决的线索。任何帮助都将不胜感激!

EN

回答 3

Stack Overflow用户

发布于 2022-07-08 02:11:32

在main.dart中添加以下内容

代码语言:javascript
运行
复制
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const Foo());
}
票数 1
EN

Stack Overflow用户

发布于 2022-08-08 19:28:18

正如所述的here,只有当设备没有安装PlayStore时,才会出现问题。

我也看到了这个错误,但似乎没有人知道解决方案。

票数 1
EN

Stack Overflow用户

发布于 2022-09-22 07:08:39

我在这里找到了解决办法。错误来自模拟器,将模拟器版本从31.3.10更改为31.2.9 https://youtu.be/qo3SbdbXFos

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72905614

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档