无法使用Firebase进行扑打; “期待活页夹,但无效!”

发布于 2025-02-13 18:41:13 字数 7157 浏览 2 评论 0 原文

我是移动应用程序的新手,并使用Firbase Auth实施Google Social Login。 我检查了官方资源,并实施了以下登录逻辑;

main.dart

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

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仿真器上敲击登录按钮(带有Android API 33,ARM64,ARM64)上的登录按钮时,我的应用程序崩溃了,Debug Console表示;

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
......

我一直在解决这个问题,但尚无线索可以解决。 任何帮助将不胜感激!

I am new to mobile app and using flutter to implement google social login with firebase auth.
I checked official resources and implemented a login logic like below;

main.dart

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

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()},
              )
            ],
          )),
        ));
  }
}

It is so simple that I expected to work, but when I tapped the sign-in button on android emulator(Pixel4 with android API 33, arm64) my app is crashed and debug console says;

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
......

I have been tackling this issue, but no clue to fix yet.
Any help would be very appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

丘比特射中我 2025-02-20 18:41:13

我在这里找到了解决方案。错误来自模拟器,将模拟器版本从31.3.10更改为31.2.9

I found the solution here. the error come from the emulator, Change the emulator version from 31.3.10 to 31.2.9 https://youtu.be/qo3SbdbXFos

行至春深 2025-02-20 18:41:13

在主要中添加此

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const Foo());
}

in main.dart add this

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const Foo());
}
卷耳 2025-02-20 18:41:13

这对我来说是间歇性的。我发现睡觉后我的设备似乎有问题。另外,我有时会断开移动热点的连接,我认为这也引起了问题。

虚拟设备的简单重新启动(冷启动)修复了它。

This would happen intermittently for me. I found that after sleep my device seemed to have problems. Also I would disconnect my mobile hotspot sometimes and I think that caused problems too.

A simple reboot (cold start) of the virtual device fixed it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文