[firebase_core] Firebase.initializeApp with demoProjectId crashes on iOS with SIGABRT (FIRInstallations validateAPIKey) - Follow-up to locked #17788
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 22/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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',
- Lingua principale
- Dart
- Stelle
- 9.3k
- Fork
- 4.1k
- Merge medio
- 2g 7h
- PR unite (30g)
- 47
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di firebase/flutterfire
-
🚀 [firebase_core] Bump Firebase Android SDK (35.0.0 → 35.0.1)Forse già presa @SelaseKay l’ha presa oggi. ApertaNeeds Attention type: enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 20/100
firebase/flutterfire#18807 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[firebase_auth]: authStateChanges() never emits null when the user is force-signed-out before the stream is listened to (iOS, macOS, Android)Forse già presa @JulianPscheid l’ha presa 3 giorni fa. ApertaNeeds Attention platform: android platform: ios platform: macos plugin: auth reproduced type: bug
Difficoltà 4/5 1-2 giorni Idoneità per principianti 15/100
firebase/flutterfire#18796 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
blocked: customer-response Needs Attention platform: ios plugin: messaging type: bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
firebase/flutterfire#18776 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[📚] Remote Config Windows Support still N/A on ReadmeForse già presa @nightcityblade l’ha presa 9 giorni fa. Apertablocked: customer-response good first issue Needs Attention platform: windows plugin: remote_config type: documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 30/100
firebase/flutterfire#18763 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[cloud_firestore]: a snapshots() listener cancelled while it registers is never removed nativelyForse già presa @chiliec l’ha presa 21 giorni fa. ApertaNeeds Attention platform: android platform: ios platform: macos plugin: cloud_firestore reproduced type: bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
firebase/flutterfire#18724 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di firebase/flutterfire
Issue simili
-
[Bug] Windows:开启 Flutter windowing 后对话框被提升为原生窗口,首个 ShowWindow 死锁导致整个应用卡死(设置 → 远程访问端口 100% 复现)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
AimesSoft/NipaPlay-Reload#1021 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
fluttercommunity/plus_plugins#4004 ·
I maintainer di solito rispondono entro 1 giorno
-
agent:ready bug P2 · 中 健壮性 区域: 启动与合规 待验证 隐私与合规
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
ASDW51/DanmuFloat#106 ·
I maintainer di solito rispondono entro 1 giorno
-
c: proposal p: go_router package team-ecosystem
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
flutter/flutter#194542 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100