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!
2
Answers
in main.dart add this
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