Flutter app fails to log in using google Sign In - firebase

Edit :- Interestingly my practice app with exact same code shows same console logs but work absolutely fine but the main app (this app) doesnt work.
My app was working fine till a few hours ago but since morning login fails with this error
E/flutter (24958): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
Stackoverflow says to change com.android.tools.build:gradle. How did this suddenly happen I dint even touch the code.
Console:
W/ActivityThread( 1327): handleWindowVisibility: no activity for token android.os.BinderProxy#1796f22
V/ViewRootImpl( 1327): The specified message queue synchronization barrier token has not been posted or has already been removed
D/DecorView( 1327): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView#d773c2a[SignInHubActivity]
D/DecorView( 1327): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView#e79156a[MainActivity]
E/flutter ( 1327): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
E/flutter ( 1327): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:572:7)
E/flutter ( 1327): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:161:18)
E/flutter ( 1327): <asynchronous suspension>
E/flutter ( 1327): #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
E/flutter ( 1327): #3 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:361:48)
E/flutter ( 1327): #4 MethodChannelGoogleSignIn.signIn (package:google_sign_in_platform_interface/src/method_channel_google_sign_in.dart:45:10)
E/flutter ( 1327): #5 GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:233:42)
E/flutter ( 1327): <asynchronous suspension>
E/flutter ( 1327): #6 GoogleSignIn._addMethodCall (package:google_sign_in/google_sign_in.dart:288:18)
E/flutter ( 1327): #7 GoogleSignIn.signIn (package:google_sign_in/google_sign_in.dart:359:9)
E/flutter ( 1327): #8 signInWithGoogle (package:opinion/services/google_sign_in.dart:8:71)
E/flutter ( 1327): #9 LoginButton.build.<anonymous closure> (package:opinion/components/login_button.dart:45:21)
E/flutter ( 1327): #10 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:992:19)
E/flutter ( 1327): #11 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1098:38)
E/flutter ( 1327): #12 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:184:24)
E/flutter ( 1327): #13 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:524:11)
E/flutter ( 1327): #14 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:284:5)
E/flutter ( 1327): #15 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:219:7)
E/flutter ( 1327): #16 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:477:9)
E/flutter ( 1327): #17 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:78:12)
E/flutter ( 1327): #18 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:124:9)
E/flutter ( 1327): #19 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter ( 1327): #20 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:122:18)
E/flutter ( 1327): #21 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:108:7)
E/flutter ( 1327): #22 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:220:19)
E/flutter ( 1327): #23 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:200:22)
E/flutter ( 1327): #24 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:158:7)
E/flutter ( 1327): #25 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:104:7)
E/flutter ( 1327): #26 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:88:7)
E/flutter ( 1327): #27 _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter ( 1327): #28 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 1327): #29 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter ( 1327): #30 _invoke1 (dart:ui/hooks.dart:267:10)
E/flutter ( 1327): #31 _dispatchPointerDataPacket (dart:ui/hooks.dart:176:5)
E/flutter ( 1327):
I/flutter ( 1327): null

These 3 lines
V/ViewRootImpl( 1327): The specified message queue synchronization barrier token has not been posted or has already been removed
D/DecorView( 1327): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView#d773c2a[SignInHubActivity]
D/DecorView( 1327): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView#e79156a[MainActivity]
E/flutter ( 1327): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
Indicate that there is an error with your SHA1 key. I think due to the new windows update the key got changed in your computer. Just generate a new one and replace it

The Platform Exception is because firebase is not being able to authenticate. Try catching the error and see the error code.
try {
[Firebase Login]
}
on PlatformException catch(error) {
print(error.code)
}

Related

Flutter: How to subscribeToTopic for Firebase (FCM) registration token in Flutter

I want to subscribeToTopic for Firebase push notification in flutter , I can subscribe to any topic but my purpose to subscribeToTopic against token , here it is the code below,
FirebaseMessaging _messaging;
Firebase.initializeApp().then((fbr) {
_messaging = FirebaseMessaging.instance;
_messaging.getToken().then((token) async{
_messaging.subscribeToTopic(token).then((value) => null);
_messaging.subscribeToTopic(userID).then((value) => null);
_messaging.subscribeToTopic(userTypeId).then((value) => null);
}
}
But I am getting error
Failed assertion: line 307 pos 10: 'isValidTopic': is not true.
log attached below:
I/flutter ( 9352): Token: dhCABsvbQ8udQJha8VOxNy:APA91bEGcpS6-QMn-c236ITNbDtxEs3MD1Q-nquedMLzZv4XWPdGUWt-Zw-OQ6YBY383IJGZXxKXNMRJd8SKLeOO7agx4dcym6VoEhPTrbYr20NoscZHTZoPCf5mqbfiTHCS5q2WlXqw
I/flutter ( 9352): User granted permission
I/flutter ( 9352): Token: dhCABsvbQ8udQJha8VOxNy:APA91bEGcpS6-QMn-c236ITNbDtxEs3MD1Q-nquedMLzZv4XWPdGUWt-Zw-OQ6YBY383IJGZXxKXNMRJd8SKLeOO7agx4dcym6VoEhPTrbYr20NoscZHTZoPCf5mqbfiTHCS5q2WlXqw
E/flutter ( 9352): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: 'package:firebase_messaging/src/messaging.dart': Failed assertion: line 307 pos 10: 'isValidTopic': is not true.
E/flutter ( 9352): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
E/flutter ( 9352): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
E/flutter ( 9352): #2 _assertTopicName (package:firebase_messaging/src/messaging.dart:307:10)
E/flutter ( 9352): #3 FirebaseMessaging.subscribeToTopic (package:firebase_messaging/src/messaging.dart:294:5)
E/flutter ( 9352): #4 _HomePageState.registerNotification.<anonymous closure> (package:notify/main.dart:89:20)
E/flutter ( 9352): #5 _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter ( 9352): #6 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter ( 9352): #7 _FutureListener.handleValue (dart:async/future_impl.dart:152:18)
E/flutter ( 9352): #8 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:704:45)
E/flutter ( 9352): #9 Future._propagateToListeners (dart:async/future_impl.dart:733:32)
E/flutter ( 9352): #10 Future._completeWithValue (dart:async/future_impl.dart:539:5)
E/flutter ( 9352): #11 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:254:13)
E/flutter ( 9352): #12 MethodChannelFirebaseMessaging.getToken (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart)
E/flutter ( 9352): <asynchronous suspension>
The error is coming up because the token id you're passing as the topic name is not an acceptable topic name.
Here is the check that the token fails:
// https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_messaging/firebase_messaging/lib/src/messaging.dart
void _assertTopicName(String topic) {
bool isValidTopic = RegExp(r'^[a-zA-Z0-9-_.~%]{1,900}$').hasMatch(topic);
assert(isValidTopic);
}
Source
Use a valid string and the code should work fine.

I am facing a problem that when I try to link the project to Firebase, I see this error

Performing hot restart...
Syncing files to device Android SDK built for x86...
Restarted application in 5,580ms.
W/DynamiteModule( 8056): Local module descriptor class for providerinstaller not found.
I/example.shopap( 8056): Background young concurrent copying GC freed 34408(1709KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 2498KB/4186KB, paused 40us total 138.555ms
I/DynamiteModule( 8056): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller( 8056): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/IInputConnectionWrapper( 8056): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper( 8056): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 8056): getTextAfterCursor on inactive InputConnection
I/BiChannelGoogleApi( 8056): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq#ed11225
E/flutter ( 8056): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: [firebase_auth/invalid-email] The email address is badly formatted.
E/flutter ( 8056): #0 catchPlatformException (package:firebase_auth_platform_interface/src/method_channel/utils/exception.dart:20:3)
E/flutter ( 8056): #1 _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter ( 8056): #2 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter ( 8056): #3 _FutureListener.handleError (dart:async/future_impl.dart:159:20)
E/flutter ( 8056): #4 Future._propagateToListeners.handleError (dart:async/future_impl.dart:694:47)
E/flutter ( 8056): #5 Future._propagateToListeners (dart:async/future_impl.dart:715:24)
E/flutter ( 8056): #6 Future._completeError (dart:async/future_impl.dart:534:5)
E/flutter ( 8056): #7 _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:43:15)
E/flutter ( 8056): #8 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart)
E/flutter ( 8056): <asynchronous suspension>
E/flutter ( 8056): #9 MethodChannelFirebaseAuth.createUserWithEmailAndPassword (package:firebase_auth_platform_interface/src/method_channel/method_channel_firebase_auth.dart:287:47)
E/flutter ( 8056): #10 FirebaseAuth.createUserWithEmailAndPassword (package:firebase_auth/src/firebase_auth.dart:186:31)
E/flutter ( 8056): #11 FirbaseAuthentication.register (package:shopapp/authentication/firebase_auth.dart:16:36)
E/flutter ( 8056): #12 _AuthTestState.build.<anonymous closure> (package:shopapp/main.dart:114:58)
E/flutter ( 8056): #13 _AuthTestState.build.<anonymous closure> (package:shopapp/main.dart:111:28)
E/flutter ( 8056): #14 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
E/flutter ( 8056): #15 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36)
E/flutter ( 8056): #16 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 8056): #17 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
E/flutter ( 8056): #18 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
E/flutter ( 8056): #19 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7)
E/flutter ( 8056): #20 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9)
E/flutter ( 8056): #21 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter ( 8056): #22 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter ( 8056): #23 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
E/flutter ( 8056): #24 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter ( 8056): #25 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter ( 8056): #26 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter ( 8056): #27 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter ( 8056): #28 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter ( 8056): #29 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter ( 8056): #30 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter ( 8056): #31 _rootRunUnary (dart:async/zone.dart:1196:13)
E/flutter ( 8056): #32 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter ( 8056): #33 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter ( 8056): #34 _invoke1 (dart:ui/hooks.dart:275:10)
E/flutter ( 8056): #35 _dispatchPointerDataPacket (dart:ui/hooks.dart:184:5)
E/flutter ( 8056):
FlutterFire has undergone some updates that include breaking changes if you're installing for the first time or migrating. What appears to be happening here is that the new packages expect to see updated Google Play packages on the emulator. However, simply installing the updated OS alone doesn't update the Google Play packages by default.
In Android Studio (it's easier there and VSC), open the "SDK Manager" and navigate to Appearance & Behavior > System Settings > Android SDK as shown below. See below as an example regarding Android 9.0. You must click "Show Package Details" in the bottom right corner.
When that is done you will see something like the following. If not already done, close the emulator. Then make sure that the "Google Play" Images are checked. Then apply and install. Restart your emulator and run/debug again. This error should go away.

Permission denied when reading from database

I have a problem reading data from a firebase database.
The code below belongs to a function attached to a [FlatButton]:
void newEntry(){
print(_database.reference().child('todo').equalTo('Dan').once().then((value){
print(value.key);
}));
}
Whenever I run this piece of code I get this error:
I/flutter (29847): Instance of 'Future<dynamic>'
D/NetworkSecurityConfig(29847): No Network Security Config specified, using platform default
W/SyncTree(29847): Listen at /todo failed: DatabaseError: Permission denied
E/flutter (29847): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: Instance of 'DatabaseError'
E/flutter (29847): #0 Query.once (package:firebase_database/src/query.dart:90:41)
E/flutter (29847): <asynchronous suspension>
E/flutter (29847): #1 _MyAppState.newEntry (package:database_project/main.dart:94:62)
E/flutter (29847): #2 _MyAppState._buildButton.<anonymous closure> (package:database_project/main.dart:88:9)
E/flutter (29847): #3 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:511:14)
E/flutter (29847): #4 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:566:30)
E/flutter (29847): #5 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:166:24)
E/flutter (29847): #6 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:240:9)
E/flutter (29847): #7 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:177:9)
E/flutter (29847): #8 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:436:9)
E/flutter (29847): #9 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
E/flutter (29847): #10 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
E/flutter (29847): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:221:19)
E/flutter (29847): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:199:22)chEvent (package:flutter/src/gestures/binding.dart:199:22) ePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (29847): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)ePointerEvent (package:flutter/src/gestures/binding.dart:156:7) ePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (29847): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (29847): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (29847): #16 _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter (29847): #17 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (29847): #18 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7) ity]
E/flutter (29847): #19 _invoke1 (dart:ui/hooks.dart:233:10)
E/flutter (29847): #20 _dispatchPointerDataPacket (dart:ui/hooks.dart:154:5) w{8084b2a VFE...... .F...... 0,0-1440,2872} of ViewRootImpl#b8c6359[MainActivity]
E/flutter (29847): t/com.example.database_project.MainActivity#8084b2a#0[29847])/#0xeeafd1b io.flutter.view.FlutterView{8084b2a VFE.D/ViewRootImpl#b8c6359[MainActivity](29847): MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputMethodManager(29847): prepareNavigationBarInfo() DecorView#48d0f7a[MainActivew{8084b2a VFE...... .F...... 0,0-1440,2872}ity]
D/InputMethodManager(29847): getNavigationBarColor() -855310D/SurfaceView(29847): onWindowVisibilityChanged(8) false io.flutter.view.FlutterView{8084b2a VFE...... .F...... 0,0-1440,2872} of ViewRootImpl#b8c6359[MainActivity]D/SurfaceView(29847): show() Surface(name=SurfaceView - com.example.database_project/com.example.database_project.MainActivity#8084b2a#0[29847])/#0xeeafd1b io.flutter.view.FlutterView{8084b2a VFE...... .F...... 0,0-1440,2872}D/SurfaceView(29847): surfaceDestroyed callback.size 1 #2 io.flutter.view.FlutterView{8084b2a VFE...... .F...... 0,0-1440,2872}W/libEGL (29847): EGLNativeWindowType 0x7af3edd010 disconnect failed
D/SurfaceView(29847): destroy() Surface(name=SurfaceView - com.example.database_project/com.example.database_project.MainActivity#8084b2a#0[29847])/#0xeeafd1b io.flutter.view.FlutterView{8084b2a VFE...... .F...... 0,0-1440,2872}W/libEGL (29847): EGLNativeWindowType 0x7b02e2a010 disconnect failedD/OpenGLRenderer(29847): eglDestroySurface = 0x7af3f13680, 0x7b02e2a000D/ViewRootImpl#b8c6359[MainActivity](29847): Relayout returned: old=[0,0][1440,3040] new=[0,0][1440,3040] result=0x5 surface={valid=false 0} changed=trueD/ViewRootImpl#b8c6359[MainActivity](29847): setWindowStopped(true) old=false
D/SurfaceView(29847): windowStopped(true) false io.flutter.view.FlutterView{8084b2a VFE...... .F...... 0,0-1440,2872} of ViewRootImpl#b8c6359[MainActivity]
D/ViewRootImpl#b8c6359[MainActivity](29847): Surface release. android.view.WindowManagerGlobal.setStoppedState:669 android.app.Activity.performStop:7647 android.app.ActivityThread.callActivityOnStop:4372 android.app.ActivityThread.performStopActivityInner:4350 android.app.ActivityThread.handleStopActivity:4425 android.app.servertransaction.StopActivityItem.execute:41 android.app.servertransaction.TransactionExecutor.executeLifecycleState:145 android.app.servertransaction.TransactionExecutor.execute:70
D/InputTransport(29847): Input channel destroyed: fd=100
I/FirebaseAuth(29847): [FirebaseAuth:] Loading module via FirebaseOptions.I/FirebaseAuth(29847): [FirebaseAuth:] Preparing to create service connection to gms implementation
As for the path of the database is todo/userId/Dan Database.
EDIT: Forgot to mention that I updated my security rules as following:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
EDIT
As per #Andrey Ilyunin comment I've authenticated my application to an user and applied the same security rules. I still get the same exception, i.e:
D/NetworkSecurityConfig( 4123): No Network Security Config specified, using platform default
W/SyncTree( 4123): Listen at /todo failed: DatabaseError: Permission denied
E/flutter ( 4123): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: Instance of 'DatabaseError'
E/flutter ( 4123): null
E/flutter ( 4123): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: Instance of 'DatabaseError'
E/flutter ( 4123): null

Flutter built value Deserialization 'failed due to: Tried to build class but nested builder for field threw: Tried to construct class with null field

I am using built value for my PODO class
Following is my code
library mobile_login_model;
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
part 'mobile_login_model.g.dart';
abstract class MobileLoginModel implements Built<MobileLoginModel, MobileLoginModelBuilder> {
MobileLoginModel._();
factory MobileLoginModel([updates(MobileLoginModelBuilder b)]) = _$MobileLoginModel;
#BuiltValueField(wireName: 'status')
int get status;
#BuiltValueField(wireName: 'msg')
String get msg;
#BuiltValueField(wireName: 'data')
MobileLoginData get data;
static Serializer<MobileLoginModel> get serializer => _$mobileLoginModelSerializer;
}
abstract class MobileLoginData implements Built<MobileLoginData, MobileLoginDataBuilder> {
MobileLoginData._();
factory MobileLoginData([updates(MobileLoginDataBuilder b)]) = _$MobileLoginData;
#BuiltValueField(wireName: 'userid')
String get userId;
#BuiltValueField(wireName: 'mobile')
String get mobile;
static Serializer<MobileLoginData> get serializer => _$mobileLoginDataSerializer;
}
Following is my http code when i click on submit button
Future<MobileLoginModel> submitMobileNumber(String mobile) async {
final response = await http.post(LOGIN_MOBILE_NUMBER_URL,body: {
"mobile": mobile
});
MobileLoginModel mobileLoginModel = standardSerializers.deserializeWith(MobileLoginModel.serializer, json.decode(response.body));
return mobileLoginModel;
}
The http request is fired whenever i enter a mobile number and click on submit button. If i enter a correct number then everything works fine
but suppose i enter a wrong number i get following error in my console
E/flutter (19934): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (19934): Deserializing '[status, 0, msg, Invalid Mobile Number.]' to 'MobileLoginModel' failed due to: Tried to build class "MobileLoginModel" but nested builder for field "data" threw: Tried to construct class "MobileLoginData" with null field "userId". This is forbidden; to allow it, mark "userId" with #nullable.
E/flutter (19934): #0 BuiltJsonSerializers._deserialize (package:built_value/src/built_json_serializers.dart:154:11)
E/flutter (19934): #1 BuiltJsonSerializers.deserialize (package:built_value/src/built_json_serializers.dart:105:18)
E/flutter (19934): #2 BuiltJsonSerializers.deserializeWith (package:built_value/src/built_json_serializers.dart:35:12)
E/flutter (19934): #3 MobileLoginApiProvider.submitMobileNumber (package:dice_clutter/resources/mobile_login/mobile_login_api_provider.dart:18:61)
E/flutter (19934): <asynchronous suspension>
E/flutter (19934): #4 MobileLoginRepository.submitMobileNumber (package:dice_clutter/resources/mobile_login/mobile_login_repository.dart:16:35)
E/flutter (19934): <asynchronous suspension>
E/flutter (19934): #5 MobileLoginBloc.submitMobileNumber (package:dice_clutter/bloc/mobile_login/mobile_login_bloc.dart:22:41)
E/flutter (19934): <asynchronous suspension>
E/flutter (19934): #6 _SubmitMobileNumberState.submitMobileNumber.<anonymous closure> (package:dice_clutter/screens/mobile_login/mobile_login.dart:177:25)
E/flutter (19934): #7 _RootZone.runUnary (dart:async/zone.dart:1379:54)
E/flutter (19934): #8 _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
E/flutter (19934): #9 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:642:45)
E/flutter (19934): #10 Future._propagateToListeners (dart:async/future_impl.dart:671:32)
E/flutter (19934): #11 Future._complete (dart:async/future_impl.dart:476:7)
E/flutter (19934): #12 _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
E/flutter (19934): #13 _AsyncAwaitCompleter.complete (dart:async/runtime/libasync_patch.dart:28:18)
E/flutter (19934): #14 _completeOnAsyncReturn (dart:async/runtime/libasync_patch.dart:295:13)
E/flutter (19934): #15 checkInternetConnection (package:dice_clutter/helpers/internet_connection.dart)
E/flutter (19934): <asynchronous suspension>
E/flutter (19934): #16 _SubmitMobileNumberState.submitMobileNumber (package:dice_clutter/screens/mobile_login/mobile_login.dart:174:5)
E/flutter (19934): #17 _SubmitMobileNumberState.build.<anonymous closure>.<anonymous closure> (package:dice_clutter/screens/mobile_login/mobile_login.dart:151:31)
E/flutter (19934): #18 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
E/flutter (19934): #19 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
E/flutter (19934): #20 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter (19934): #21 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter (19934): #22 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
E/flutter (19934): #23 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
E/flutter (19934): #24 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
E/flutter (19934): #25 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
E/flutter (19934): #26 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:180:19)
E/flutter (19934): #27 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
E/flutter (19934): #28 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
E/flutter (19934): #29 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
E/flutter (19934): #30 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
E/flutter (19934): #31 _invoke1 (dart:ui/hooks.dart:168:13)
E/flutter (19934): #32 _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)
Because the data property is missing in the received JSON {"status": 0, "msg": "Invalid Mobile Number."} it needs to be nullable. By default all properties are non-nullable.
#nullable
#BuiltValueField(wireName: 'data')
MobileLoginData get data;
https://pub.dartlang.org/documentation/built_value/latest/built_value/nullable-constant.html

PlatformException(sign_in_failed, Status{statusCode=DEVELOPER_ERROR, resolution=null}, null) error in flutter [duplicate]

This question already has answers here:
Error: Status{statusCode=DEVELOPER_ERROR, resolution=null}
(25 answers)
Closed 3 years ago.
I have an app that has a list of cards and for cards, I saved texts in firebase database and images in firebase storage. I want to implement google-sign-in for my app. I added SHA1 and SHA256 and I followed steps in this tutorial for implementing google sign-in. Now when I clicked for login I see it's not working (you can see in file). I'm trying many ways for 3 days and I couldn't solve it!
here is all of my codes.
and here is my log:
W/ActivityThread( 7024): handleWindowVisibility: no activity for token android.os.BinderProxy#bb6d004
D/EGL_emulation( 7024): eglMakeCurrent: 0xe7a85480: ver 2 0 (tinfo 0xe7a83750)
D/EGL_emulation( 7024): eglMakeCurrent: 0xe7a85480: ver 2 0 (tinfo 0xe7a83750)
E/flutter ( 7024): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter ( 7024): PlatformException(sign_in_failed, Status{statusCode=DEVELOPER_ERROR, resolution=null}, null)
E/flutter ( 7024): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7)
E/flutter ( 7024): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:279:18)
E/flutter ( 7024): <asynchronous suspension>
E/flutter ( 7024): #2 GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:185:58)
E/flutter ( 7024): <asynchronous suspension>
E/flutter ( 7024): #3 GoogleSignIn._addMethodCall (package:google_sign_in/google_sign_in.dart:224:20)
E/flutter ( 7024): #4 GoogleSignIn.signIn (package:google_sign_in/google_sign_in.dart:292:48)
E/flutter ( 7024): #5 FBApi.signInWithGoogle (package:firebase_example/Model/Api.dart:18:64)
E/flutter ( 7024): <asynchronous suspension>
E/flutter ( 7024): #6 LoginPageState._loginUser (package:firebase_example/Ui/LoginPage.dart:19:29)
E/flutter ( 7024): <asynchronous suspension>
E/flutter ( 7024): #7 LoginPageState.build.<anonymous closure> (package:firebase_example/Ui/LoginPage.dart:81:42)
E/flutter ( 7024): <asynchronous suspension>
E/flutter ( 7024): #8 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:503:14)
E/flutter ( 7024): #9 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:558:30)
E/flutter ( 7024): #10 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
E/flutter ( 7024): #11 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
E/flutter ( 7024): #12 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
E/flutter ( 7024): #13 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
E/flutter ( 7024): #14 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
E/flutter ( 7024): #15 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
E/flutter ( 7024): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19)
E/flutter ( 7024): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22)
E/flutter ( 7024): #18 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7)
E/flutter ( 7024): #19 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7)
E/flutter ( 7024): #20 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7)
E/flutter ( 7024): #21 _invoke1 (dart:ui/hooks.dart:142:13)
E/flutter ( 7024): #22 _dispatchPointerDataPacket (dart:ui/hooks.dart:99:5)
W/ActivityThread( 7024): handleWindowVisibility: no activity for token android.os.BinderProxy#53cfd59
I/firebaseexampl( 7024): WaitForGcToComplete blocked Background on None for 8.655ms
I/firebaseexampl( 7024): Waiting for a blocking GC ProfileSaver
I/firebaseexampl( 7024): Background concurrent copying GC freed 18668(1149KB) AllocSpace objects, 12(624KB) LOS objects, 49% free, 2MB/5MB, paused 3.574ms total 196.627ms
I/firebaseexampl( 7024): WaitForGcToComplete blocked ProfileSaver on ProfileSaver for 49.287ms
W/firebaseexampl( 7024): Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (light greylist, linking)
D/EGL_emulation( 7024): eglMakeCurrent: 0xe7a85480: ver 2 0 (tinfo 0xe7a83750)
E/flutter ( 7024): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter ( 7024): PlatformException(sign_in_failed, Status{statusCode=DEVELOPER_ERROR, resolution=null}, null)
E/flutter ( 7024): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7)
E/flutter ( 7024): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:279:18)
E/flutter ( 7024): <asynchronous suspension>
E/flutter ( 7024): #2 GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:185:58)
E/flutter ( 7024): <asynchronous suspension>
E/flutter ( 7024): #3 GoogleSignIn._addMethodCall.<anonymous closure> (package:google_sign_in/google_sign_in.dart:237:28)
E/flutter ( 7024): #4 _RootZone.run (dart:async/zone.dart:1374:54)
E/flutter ( 7024): #5 _FutureListener.handleWhenComplete (dart:async/future_impl.dart:153:18)
E/flutter ( 7024): #6 Future._propagateToListeners.handleWhenCompleteCallback (dart:async/future_impl.dart:612:39)
E/flutter ( 7024): #7 Future._propagateToListeners (dart:async/future_impl.dart:668:37)
E/flutter ( 7024): #8 Future._addListener.<anonymous closure> (dart:async/future_impl.dart:351:9)
E/flutter ( 7024): #9 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter ( 7024): #10 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
D/EGL_emulation( 7024): eglMakeCurrent: 0xe7a85480: ver 2 0 (tinfo 0xe7a83750)
Copy the ID of the client that is in your project https://console.developers.google.com.
Paste the ID to your resources String the Android project
Finally add .requestIdToken (getString (R.string.default_web_client_id))
GoogleSignInOptions gso = new GoogleSignInOptions
.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
I hope it has been helpfull :)

Resources