Flutter NSException:配置失败。可能是GoogleService-Info.plist中无效的GOOGLE_APP_ID或自定义选项中设置的
Flutter NSException: Configuration fails. It may be caused by an invalid GOOGLE_APP_ID in GoogleService-Info.plist or set in the customized options
GoogleService-Info.plist 文件是通过 Add Files to "Runner" 选项添加的。所以,它在 Runner 目录中。
我已经检查了很多堆栈溢出的答案,但无法找出问题所在。
我也在 GoogleService 中重新检查 GOOGLE_APP_ID-Info.plist
GoogleService-Info.plist配置没有问题。
我还将下面的 CFBundleURLTypes 属性添加到 [my_project]/ios/Runner/Info.plist 文件中。
CFBundleURLTypes - CFBundleTypeRole - 编辑器 - CFBundleURLSchemes -com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn
问题日志:
2020-07-08 09:57:50.535551+0545 Sefyl [63114:5254473] flutter: Observatory listening on http://127.0.0.1:53595/jh2o62kCyXk=/
2020-07-08 09:57:50.815919+0545 Sefyl [63114:5254485] 6.25.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60501000 started
2020-07-08 09:57:50.851101+0545 Sefyl [63114:5254418] 6.25.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2020-07-08 09:57:50.851571+0545 Sefyl [63114:5254418] 6.25.0 - [Firebase/Analytics][I-ACS031025] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2020-07-08 09:57:51.366223+0545 Sefyl [63114:5254423] 6.25.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-07-08 09:57:51.500886+0545 Sefyl [63114:5254426] 6.25.0 - [Firebase/Core][I-COR000004] App with name test does not exist.
2020-07-08 09:57:51.508053+0545 Sefyl [63114:5254426] 6.25.0 - [Firebase/Core][I-COR000009] The GOOGLE_APP_ID either in the plist file 'GoogleService-Info.plist' or the one set in the customized options is invalid. If you are using the plist file, use the iOS version of bundle identifier to download the file, and do not manually edit the GOOGLE_APP_ID. You may change your app's bundle identifier to 'com.sefyl.goflutter'. Or you can download a new configuration file that matches your bundle identifier from https://console.firebase.google.com/ and replace the current one.
2020-07-08 09:57:51.581320+0545 Sefyl [63114:5254055] *** Terminating app due to uncaught exception 'com.firebase.core', reason: 'Configuration fails. It may be caused by an invalid GOOGLE_APP_ID in GoogleService-Info.plist or set in the customized options.'
*** First throw call stack:
.....
...
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
终于解决了!
简单地说,根据其平台配置 GoogleService-Info.plist 和 GoogleService.json:
// config acc to platform
final FirebaseOptions firebaseOptions = (Platform.isIOS || Platform.isMacOS)
? const FirebaseOptions(
googleAppID: '1:926446789922:ios:e1628wrtecf870f0717b',
gcmSenderID: '2564624562546',
apiKey: 'AIzaSyChk3KEG7QYrs4kQfgNxBTbwerwrfCAdgg',
projectID: 'project-23f',
storageBucket: 'gs://project-23f.appspot.com',
databaseURL: 'https://project-23f.firebaseio.com/',
)
: const FirebaseOptions(
googleAppID: '1:926446789922:android:056bd6d9f0717b',
gcmSenderID: '2564624562546',
apiKey: 'AIzaSyDBq2tJ82wO0RKzfsguGCp7e6uh3Ko',
projectID: 'project-23f',
storageBucket: 'gs://project-23f.appspot.com',
databaseURL: 'https://project-23f.firebaseio.com/',
);
final FirebaseApp app =
await FirebaseApp.configure(name: 'test', options: firebaseOptions);
GoogleService-Info.plist 文件是通过 Add Files to "Runner" 选项添加的。所以,它在 Runner 目录中。
我已经检查了很多堆栈溢出的答案,但无法找出问题所在。
我也在 GoogleService 中重新检查 GOOGLE_APP_ID-Info.plist
GoogleService-Info.plist配置没有问题。
我还将下面的 CFBundleURLTypes 属性添加到 [my_project]/ios/Runner/Info.plist 文件中。
CFBundleURLTypes - CFBundleTypeRole - 编辑器 - CFBundleURLSchemes -com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn
问题日志:
2020-07-08 09:57:50.535551+0545 Sefyl [63114:5254473] flutter: Observatory listening on http://127.0.0.1:53595/jh2o62kCyXk=/
2020-07-08 09:57:50.815919+0545 Sefyl [63114:5254485] 6.25.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60501000 started
2020-07-08 09:57:50.851101+0545 Sefyl [63114:5254418] 6.25.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2020-07-08 09:57:50.851571+0545 Sefyl [63114:5254418] 6.25.0 - [Firebase/Analytics][I-ACS031025] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist
2020-07-08 09:57:51.366223+0545 Sefyl [63114:5254423] 6.25.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2020-07-08 09:57:51.500886+0545 Sefyl [63114:5254426] 6.25.0 - [Firebase/Core][I-COR000004] App with name test does not exist.
2020-07-08 09:57:51.508053+0545 Sefyl [63114:5254426] 6.25.0 - [Firebase/Core][I-COR000009] The GOOGLE_APP_ID either in the plist file 'GoogleService-Info.plist' or the one set in the customized options is invalid. If you are using the plist file, use the iOS version of bundle identifier to download the file, and do not manually edit the GOOGLE_APP_ID. You may change your app's bundle identifier to 'com.sefyl.goflutter'. Or you can download a new configuration file that matches your bundle identifier from https://console.firebase.google.com/ and replace the current one.
2020-07-08 09:57:51.581320+0545 Sefyl [63114:5254055] *** Terminating app due to uncaught exception 'com.firebase.core', reason: 'Configuration fails. It may be caused by an invalid GOOGLE_APP_ID in GoogleService-Info.plist or set in the customized options.'
*** First throw call stack:
.....
...
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
终于解决了!
简单地说,根据其平台配置 GoogleService-Info.plist 和 GoogleService.json:
// config acc to platform
final FirebaseOptions firebaseOptions = (Platform.isIOS || Platform.isMacOS)
? const FirebaseOptions(
googleAppID: '1:926446789922:ios:e1628wrtecf870f0717b',
gcmSenderID: '2564624562546',
apiKey: 'AIzaSyChk3KEG7QYrs4kQfgNxBTbwerwrfCAdgg',
projectID: 'project-23f',
storageBucket: 'gs://project-23f.appspot.com',
databaseURL: 'https://project-23f.firebaseio.com/',
)
: const FirebaseOptions(
googleAppID: '1:926446789922:android:056bd6d9f0717b',
gcmSenderID: '2564624562546',
apiKey: 'AIzaSyDBq2tJ82wO0RKzfsguGCp7e6uh3Ko',
projectID: 'project-23f',
storageBucket: 'gs://project-23f.appspot.com',
databaseURL: 'https://project-23f.firebaseio.com/',
);
final FirebaseApp app =
await FirebaseApp.configure(name: 'test', options: firebaseOptions);