Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[google_maps_flutter] Plugin Crashes Without a Helpful Error message on iOS If No API Key Specified #17894

Open
gerryhigh opened this issue May 25, 2018 · 6 comments
Labels
a: error message Error messages from the Flutter framework c: crash Stack traces logged to the console c: fatal crash Crashes that terminate the process found in release: 2.0 Found to occur in 2.0 found in release: 2.2 Found to occur in 2.2 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: maps Google Maps plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team

Comments

@gerryhigh
Copy link

gerryhigh commented May 25, 2018

https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter

If you don't include the API key in an iOS app the google_maps_flutter plugin will crash hard with the following with no indication as to why:

*** First throw call stack:
(
        0   CoreFoundation                      0x000000010cd3912b __exceptionPreprocess + 171
        1   libobjc.A.dylib                     0x000000010c3cdf41 objc_exception_throw + 48
        2   CoreFoundation                      0x000000010cdae245 +[NSException raise:format:] + 197
        3   Runner                              0x00000001058b5723 +[GMSServices checkServicePreconditions] + 182
        4   Runner                              0x00000001058b2562 +[GMSServices sharedServicesSync] + 110
        5   Runner                              0x00000001058a1fb9 -[GMSMapView sharedInitWithServices:camera:forPlaces:] + 156
        6   Runner                              0x00000001058a1421 -[GMSMapView initWithFrame:camera:] + 123
        7   Runner                              0x00000001058a1245 +[GMSMapView mapWithFrame:camera:] + 104
        8   Runner <…>

Only if you run "flutter run -v" will you get the actual reason:

[ +111 ms] [DEVICE LOG] 2018-05-24 20:41:34.563396-0500  localhost Runner[72738]: (CoreFoundation) *** Terminating app due to uncaught exception 'GMSServicesException', reason: 'Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:...] prior to use'
[        ] [DEVICE LOG] *** First throw call stack:

It seems kind of harsh. If possible it would be nice to display a console message at the minimum.

@zoechi zoechi added c: crash Stack traces logged to the console plugin labels Aug 3, 2018
@rohan20
Copy link

rohan20 commented Dec 26, 2018

For me, the maps demo on iOS didn't work even when I had the API key added in the AppDelegate.m file as per the setup instructions from the package: Google Maps Flutter

Solution:

  1. Open AppDelegate.swift
  2. Add import GoogleMaps along with the other imports
  3. Add the following statement above GeneratedPluginRegistrant.register(with: self): GMSServices.provideAPIKey("YOUR_API_KEY_HERE") where YOUR_API_KEY would be something like AIzaSyBHV....wZEIg from the Cloud Console.

You can then delete the following line from AppDelegate.m if it is there:
[GMSServices provideAPIKey:@"YOUR_API_KEY];

@zoechi zoechi added the p: maps Google Maps plugin label Jan 8, 2019
@zoechi zoechi added this to the Goals milestone Jan 8, 2019
@vishalbuha
Copy link

i also have same issue but now its fix

please check your AppDelegate.swift

  1. import GoogleMaps
    2)GMSServices.provideAPIKey("YOUR_API_KEY")

@TahaTesser TahaTesser added the platform-ios iOS applications specifically label Mar 16, 2020
@kf6gpe kf6gpe added the P2 Important issues not at the top of the work list label May 29, 2020
@Hixie Hixie removed this from the None. milestone Aug 17, 2020
@TahaTesser
Copy link
Member

TahaTesser commented Apr 20, 2021

If we omit the API key, the app fatally crashes without a helpful error message

Flutter logs

[   +7 ms] Connected to _flutterView/0x7fa99081f620.
[   +5 ms] Flutter run key commands.
[   +1 ms] r Hot reload. 🔥🔥🔥
[        ] R Hot restart.
[        ] h Repeat this help message.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] Running with unsound null safety
[        ] For more information see https://dart.dev/null-safety/unsound-null-safety
[        ] An Observatory debugger and profiler on iPhone 12 is available at: http://127.0.0.1:62906/2rq_bzN9_jE=/
[ +139 ms] Service protocol connection closed.
[        ] Lost connection to device.
[   +5 ms] DevFS: Deleting filesystem on the device
(file:///Users/tahatesser/Library/Developer/CoreSimulator/Devices/83060656-28E7-44CD-801E-B11EC3EC89BA/data/Containers/Data/Applicat
ion/31A53DE2-A431-4AF0-8C50-999695D17564/tmp/stable_flutterNh91DP/stable_flutter/)
[ +257 ms] Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not completed
[   +6 ms] "flutter run" took 22,544ms.
[ +259 ms] ensureAnalyticsSent: 253ms
[   +1 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 0
tahatesser@Tahas-MBP stable_flutter % 

Xcode logs

logs
2021-04-20 15:55:25.036888+0300 Runner[32042:361933] Metal GPU Frame Capture Enabled
2021-04-20 15:55:25.037847+0300 Runner[32042:361933] Metal API Validation Enabled
2021-04-20 15:55:25.197789+0300 Runner[32042:362420] flutter: Observatory listening on http://127.0.0.1:63106/A1ZZV6nU1tc=/
2021-04-20 15:55:26.057039+0300 Runner[32042:361933] *** Terminating app due to uncaught exception 'GMSServicesException', reason: 'Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:...] prior to use'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff20421af6 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007fff20177e78 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff204219d4 -[NSException initWithCoder:] + 0
	3   Runner                              0x000000010c7577d6 +[GMSServices checkServicePreconditions] + 245
	4   Runner                              0x000000010c75496f +[GMSServices sharedServicesSync] + 110
	5   Runner                              0x000000010c740cbb -[GMSMapView initWithFrame:camera:] + 59
	6   Runner                              0x000000010c740be2 +[GMSMapView mapWithFrame:camera:] + 90
	7   Runner                              0x000000010cb9e602 -[FLTGoogleMapController initWithFrame:viewIdentifier:arguments:registrar:] + 354
	8   Runner                              0x000000010cb9e44d -[FLTGoogleMapFactory createWithFrame:viewIdentifier:arguments:] + 141
	9   Flutter                             0x000000010d6d6f1c _ZN7flutter30FlutterPlatformViewsController8OnCreateEP17FlutterMethodCallRU13block_pointerFvP11objc_objectE + 488
	10  Flutter                             0x000000010d6d0598 __47-[FlutterEngine maybeSetupPlatformViewChannels]_block_invoke.165 + 120
	11  Flutter                             0x000000010da76316 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 104
	12  Flutter                             0x000000010d6f561c _ZNK7flutter21PlatformMessageRouter21HandlePlatformMessageEN3fml6RefPtrINS_15PlatformMessageEEE + 166
	13  Flutter                             0x000000010d6fa7fe _ZN7flutter15PlatformViewIOS21HandlePlatformMessageEN3fml6RefPtrINS_15PlatformMessageEEE + 38
	14  Flutter                             0x000000010daa10c3 _ZNSt3__110__function6__funcIZN7flutter5Shell29OnEngineHandlePlatformMessageEN3fml6RefPtrINS2_15PlatformMessageEEEE4$_38NS_9allocatorIS8_EEFvvEEclEv + 83
	15  Flutter                             0x000000010da1f084 _ZN3fml15MessageLoopImpl10FlushTasksENS_9FlushTypeE + 160
	16  Flutter                             0x000000010da2423c _ZN3fml17MessageLoopDarwin11OnTimerFireEP16__CFRunLoopTimerPS0_ + 26
	17  CoreFoundation                      0x00007fff20390c57 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
	18  CoreFoundation                      0x00007fff2039072a __CFRunLoopDoTimer + 926
	19  CoreFoundation                      0x00007fff2038fcdd __CFRunLoopDoTimers + 265
	20  CoreFoundation                      0x00007fff2038a35e __CFRunLoopRun + 1949
	21  CoreFoundation                      0x00007fff203896d6 CFRunLoopRunSpecific + 567
	22  GraphicsServices                    0x00007fff2c257db3 GSEventRunModal + 139
	23  UIKitCore                           0x00007fff24696cf7 -[UIApplication _run] + 912
	24  UIKitCore                           0x00007fff2469bba8 UIApplicationMain + 101
	25  Runner                              0x000000010c730ecb main + 75
	26  libdyld.dylib                       0x00007fff2025a3e9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'GMSServicesException', reason: 'Google Maps SDK for iOS must be initialized via [GMSServices provideAPIKey:...] prior to use'
terminating with uncaught exception of type NSException
CoreSimulator 732.18.6 - Device: iPhone 12 (83060656-28E7-44CD-801E-B11EC3EC89BA) - Runtime: iOS 14.4 (18D46) - DeviceType: iPhone 12
(lldb) 
flutter doctor -v
[✓] Flutter (Channel stable, 2.0.5, on macOS 11.2.3 20D91 darwin-x64, locale
    en-GB)
    • Flutter version 2.0.5 at /Users/tahatesser/Code/flutter_stable
    • Framework revision adc687823a (4 days ago), 2021-04-16 09:40:20 -0700
    • Engine revision b09f014e96
    • Dart version 2.12.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Volumes/Extreme/SDK
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /Volumes/Extreme/SDK
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.55.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (3 available)
    • iPhone 12 (mobile) • 83060656-28E7-44CD-801E-B11EC3EC89BA • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    • macOS (desktop)    • macos                                • darwin-x64
      • macOS 11.2.3 20D91 darwin-x64
    • Chrome (web)       • chrome                               • web-javascript
      • Google Chrome 89.0.4389.128

• No issues found!
[✓] Flutter (Channel master, 2.2.0-11.0.pre.176, on macOS 11.2.3 20D91
    darwin-x64, locale en-GB)
    • Flutter version 2.2.0-11.0.pre.176 at
      /Users/tahatesser/Code/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cceeaa075 (7 hours ago), 2021-04-20 02:24:02 -0400
    • Engine revision 7f4d7c67a5
    • Dart version 2.14.0 (build 2.14.0-8.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Volumes/Extreme/SDK
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /Volumes/Extreme/SDK
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)

[!] IntelliJ IDEA Community Edition (version unknown)
    ✗ Invalid IntelliJ version number.

[✓] VS Code (version 1.55.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (3 available)
    • iPhone 12 (mobile) • 83060656-28E7-44CD-801E-B11EC3EC89BA • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    • macOS (desktop)    • macos                                • darwin-x64
      • macOS 11.2.3 20D91 darwin-x64
    • Chrome (web)       • chrome                               • web-javascript
      • Google Chrome 89.0.4389.128

! Doctor found issues in 1 category.

@TahaTesser TahaTesser added a: error message Error messages from the Flutter framework found in release: 2.0 Found to occur in 2.0 found in release: 2.2 Found to occur in 2.2 has reproducible steps The issue has been confirmed reproducible and is ready to work on c: fatal crash Crashes that terminate the process labels Apr 20, 2021
@TahaTesser TahaTesser changed the title Google Maps Flutter plugin crashes with core dump on iOS if no api key specified [google_maps_flutter] Plugin Crashes Without a Helpful Error message on iOS If No API Key Specified Apr 20, 2021
@jmagman
Copy link
Member

jmagman commented Sep 30, 2021

Similar to #22536.

@Siyaho

This comment was marked as off-topic.

@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
@Hixie Hixie removed the plugin label Jul 6, 2023
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: error message Error messages from the Flutter framework c: crash Stack traces logged to the console c: fatal crash Crashes that terminate the process found in release: 2.0 Found to occur in 2.0 found in release: 2.2 Found to occur in 2.2 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: maps Google Maps plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team
Projects
Development

No branches or pull requests