[firebase_core] Firebase.initializeApp with demoProjectId crashes on iOS with SIGABRT (FIRInstallations validateAPIKey) - Follow-up to locked #17788
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start in firebase_core/lib/src/firebase.dart, where demoProjectId builds the FirebaseOptions with the hardcoded apiKey '12345'. Reproduce with the linked repro project on an iOS simulator to see the SIGABRT from FIRInstallations validateAPIKey. Pull request #18792 already targets this, so check it before starting. Done means the demo options pass validation on Apple platforms and the repro app launches without crashing.
索引モデルが issue の本文から書いたものです。
説明
Description
This is a follow-up to locked issue #17788. I have created a clean, minimal reproduction project with no remote Firebase project, no GoogleService-Info.plist, and no google-services.json:
👉 Reproduction Repository: https://github.com/akurnaz/flutterfire_repro
The issue is that Firebase.initializeApp(demoProjectId: '...') crashes natively on iOS (EXC_CRASH (SIGABRT) / Abort trap: 6) as soon as any package that depends on FirebaseInstallations (e.g., firebase_crashlytics, firebase_auth, or firebase_messaging) is present.
Steps to Reproduce
- Clone the reproduction repo:
git clone https://github.com/akurnaz/flutterfire_repro.git - Run on an iOS Simulator:
flutter run - The application crashes immediately on startup.
Alternatively, in any fresh Flutter app:
- Add
firebase_core: ^4.15.0andfirebase_crashlytics: ^5.4.0(which pulls inFirebaseInstallations). - Call
await Firebase.initializeApp(demoProjectId: 'demo-template');inmain().
Crash Stack Trace
Termination: SIGNAL (Abort trap: 6 / SIGABRT)
CoreFoundation - __exceptionPreprocess
libobjc.A.dylib - objc_exception_throw
Runner - +[FIRInstallations validateAPIKey:]
Runner - +[FIRInstallations validateAppOptions:appName:]
Runner - -[FIRInstallations initWithAppOptions:appName:installationsIDController:prefetchAuthToken:]
Runner - -[FIRInstallations initWithApp:]
Runner - __40+[FIRInstallations componentsToRegister]_block_invoke
Runner - -[FIRComponentContainer instantiateInstanceForProtocol:withBlock:]
Runner - -[FIRComponentContainer instanceForProtocol:]
Runner - -[FIRComponentContainer instantiateEagerComponents]
Runner - +[FIRApp configureWithName:options:]
Runner - FLTFirebaseCorePlugin.initializeApp(appName:initializeAppRequest:completion:)
Root Cause
- In
firebase_core/lib/src/firebase.dart,demoProjectIdsets a hardcoded dummy API key:
resolvedOptions = FirebaseOptions(
apiKey: '12345',
appId: '1:1:$platformString:1',
messagingSenderId: '',
projectId: demoProjectId,
);
- In the iOS native SDK (
firebase-ios-sdk),FIRInstallations.mstrictly validates that the API key is 39 characters and begins withA:
+ (void)validateAPIKey:(nullable NSString *)APIKey {
if (APIKey.length != kExpectedAPIKeyLength) { // kExpectedAPIKeyLength = 39
[validationIssues addObject:@"API Key length must be 39 characters"];
}
if (![[APIKey substringToIndex:1] isEqualToString:@"A"]) {
[validationIssues addObject:@"API Key must start with `A`"];
}
if (validationIssues.count > 0) {
[NSException raise:kFirebaseInstallationsErrorDomain format:...];
}
}
- Because
'12345'fails this validation, an uncaughtNSExceptionis thrown, resulting in an uncatchableSIGABRTcrash on iOS.
Suggested Fix
In firebase_core/lib/src/firebase.dart, format the dummy apiKey to be a 39-character string starting with A on Apple platforms:
apiKey: (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS)
? 'AIzaSy0000000000000000000000000000000'
: '12345',
- 主要言語
- Dart
- スター
- 9.3k
- フォーク
- 4.1k
- 平均マージ
- 2日 8時間
- マージ済み PR(30日)
- 46
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
firebase/flutterfire のほかの issue
-
[firebase_auth]: authStateChanges() never emits null when the user is force-signed-out before the stream is listened to (iOS, macOS, Android)対応中かも @JulianPscheid が 1 日前に担当しました。 オープンNeeds Attention platform: android platform: ios platform: macos plugin: auth reproduced type: bug
難易度 4/5 1〜2日 初心者へのやさしさ 15/100
firebase/flutterfire#18796 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
blocked: customer-response Needs Attention platform: ios plugin: messaging type: bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
firebase/flutterfire#18776 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
[📚] Remote Config Windows Support still N/A on Readme対応中かも @nightcityblade が 7 日前に担当しました。 オープンblocked: customer-response good first issue Needs Attention platform: windows plugin: remote_config type: documentation
難易度 1/5 1時間未満 初心者へのやさしさ 30/100
firebase/flutterfire#18763 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
[cloud_firestore]: a snapshots() listener cancelled while it registers is never removed natively対応中かも @chiliec が 19 日前に担当しました。 オープンNeeds Attention platform: android platform: ios platform: macos plugin: cloud_firestore reproduced type: bug
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
firebase/flutterfire#18724 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[firebase_storage] Windows native crash in upload progress callback, sink ownership and thread dispatch再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンblocked: flutter platform: windows plugin: storage reproduced type: bug
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
firebase/flutterfire#18664 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
firebase/flutterfire の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: The daily reminder keeps its old language after the app language changes対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbacklog:low bug localization
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
simonoppowa/OpenNutriTracker#1366 ·
メンテナーはふだん 1 日以内に返信
-
Mobile reading view shows a sender without display name as "<[email protected]>" with angle bracketsオープンai-driven-qa bug Cosmetic
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
linagora/tmail-flutter#4999 ·
メンテナーはふだん 1 日以内に返信
-
waiting for response
難易度 2/5 1時間未満 初心者へのやさしさ 72/100
flutter/flutter#194381 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
newrelic/newrelic-flutter-agent#243 · コメント 3 件 ·