未处理的异常:类型'PlatformException'不是类型'String'的子类型

时间:2020-08-24 13:42:27

标签: flutter dart

  • 现在使用Google登录API已有一个月了
  • 在Google登录之前获取此错误
  • 更改了Cloud Firestore规则,但仍显示相同的结果
  • API错误? (sign_in_failed,com.google.android.gms.common.api.ApiException:10 :,空)

E/flutter ( 8552): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: type 'PlatformException' is not a subtype of type 'String'
E/flutter ( 8552): #0      _SignInState.initState.<anonymous closure> (package:event_management/google_signin.dart:35:32)
E/flutter ( 8552): #1      _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter ( 8552): #2      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 8552): #3      _FutureListener.handleError (dart:async/future_impl.dart:160:20)
E/flutter ( 8552): #4      Future._propagateToListeners.handleError (dart:async/future_impl.dart:708:47)
E/flutter ( 8552): #5      Future._propagateToListeners (dart:async/future_impl.dart:729:24)
E/flutter ( 8552): #6      Future._completeError (dart:async/future_impl.dart:537:5)
E/flutter ( 8552): #7      _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:47:15)
E/flutter ( 8552): #8      GoogleSignIn.signInSilently (package:google_sign_in/google_sign_in.dart)
E/flutter ( 8552): <asynchronous suspension>
E/flutter ( 8552): #9      _SignInState.initState (package:event_management/google_signin.dart:32:13)
E/flutter ( 8552): #10     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4684:58)
E/flutter ( 8552): #11     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4520:5)
E/flutter ( 8552): #12     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #13     Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #14     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter ( 8552): #15     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #16     Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #17     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
E/flutter ( 8552): #18     Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
E/flutter ( 8552): #19     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4525:5)
E/flutter ( 8552): #20     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4520:5)
E/flutter ( 8552): #21     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #22     Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #23     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter ( 8552): #24     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #25     Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #26     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter ( 8552): #27     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #28     Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #29     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
E/flutter ( 8552): #30     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)
E/flutter ( 8552): #31     Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
E/flutter ( 8552): #32     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4525:5)
E/flutter ( 8552): #33     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4710:11)
E/flutter ( 8552): #34     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4520:5)
E/flutter ( 8552): #35     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #36     Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #37     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter ( 8552): #38     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #39     Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #40     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5874:14)
E/flutter ( 8552): #41     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
E/flutter ( 8552): #42     Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
E/flutter ( 8552): #43     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
E/flutter ( 8552): #44     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)
E/flutter ( 8552): #45     Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
E/flutter ( 8552): #46     ComponentElement._firstBuild (package 

Cloud Firestore规则:

`

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.time < timestamp.date(2020, 8, 31);
    }
  }
}

`

1 个答案:

答案 0 :(得分:0)

原因:

  • 此问题是由于我在外部ssd中重新安装了Android Studio之后发生的,因此SHA-1值已更改。

解决方案:

  • 在gradlew终端中使用“ gradlew signingReport”命令再次获取SHA-1。
  • 向Firebase中添加新的SHA-1值,这可能会解决您的问题。