发布到 App Store 后,Google Maps SDK for iOS 崩溃

3

我在我的iOS应用程序中集成了Google地图(v1.5),在真实设备(iPad 4 iOS 6.1)上以调试模式测试时运行良好。

我发布了我的应用程序,当用户打开地图时,应用程序会崩溃。

我无法确定问题出在哪里以及为什么会崩溃。

编辑:

崩溃报告:

Exception Type:  EXC_CRASH (SIGABRT)

Exception Codes: 0x0000000000000000, 0x0000000000000000

Crashed Thread:  0


Last Exception Backtrace:

0   CoreFoundation                0x366333e2 __exceptionPreprocess + 158

1   libobjc.A.dylib               0x33b6695e objc_exception_throw + 26

2   CoreFoundation                0x36636dbc +[NSObject(NSObject) doesNotRecognizeSelector:] + 180

3   CoreFoundation                0x36635648 ___forwarding___ + 388

4   CoreFoundation                0x3658d204 _CF_forwarding_prep_0 + 20

5   myApp                        0x00053286 -[ELocation loadView] (ELocation.m:45)

6   UIKit                         0x309eb414 -[UIViewController loadViewIfRequired] + 64

7   UIKit                         0x30a65f7c -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 80

8   UIKit                         0x30a65f22 -[UITabBarController transitionFromViewController:toViewController:] + 26

9   UIKit                         0x30a100a8 -[UITabBarController _setSelectedViewController:] + 292

10  UIKit                         0x30b0569c -[UITabBarController _tabBarItemClicked:] + 268

11  UIKit                         0x30ab703a -[UIApplication sendAction:to:from:forEvent:] + 66

12  UIKit                         0x30ab6fee -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26

13  UIKit                         0x30b05564 -[UITabBar _sendAction:withEvent:] + 380

14  UIKit                         0x30ab703a -[UIApplication sendAction:to:from:forEvent:] + 66

15  UIKit                         0x30ab6fee -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26

16  UIKit                         0x30ab6fc8 -[UIControl sendAction:to:forEvent:] + 40

17  UIKit                         0x30ab687e -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 498

18  UIKit                         0x30ab703a -[UIApplication sendAction:to:from:forEvent:] + 66

19  UIKit                         0x30ab6fee -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26

20  UIKit                         0x30ab6fc8 -[UIControl sendAction:to:forEvent:] + 40

21  UIKit                         0x30ab687e -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 498

22  UIKit                         0x30ab6d6c -[UIControl touchesEnded:withEvent:] + 484

23  UIKit                         0x309df5bc -[UIWindow _sendTouchesForEvent:] + 520

24  UIKit                         0x309cc8a4 -[UIApplication sendEvent:] + 376

25  UIKit                         0x309cc1b2 _UIApplicationHandleEvent + 6194

26  GraphicsServices              0x365465f2 _PurpleEventCallback + 586

27  GraphicsServices              0x36546222 PurpleEventCallback + 30

28  CoreFoundation                0x366083e2 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 30

29  CoreFoundation                0x36608386 __CFRunLoopDoSource1 + 134

30  CoreFoundation                0x3660720a __CFRunLoopRun + 1378

31  CoreFoundation                0x3657a238 CFRunLoopRunSpecific + 352

32  CoreFoundation                0x3657a0c4 CFRunLoopRunInMode + 100

33  GraphicsServices              0x36545336 GSEventRunModal + 70

34  UIKit                         0x30a20284 UIApplicationMain + 1116

35  myApp                        0x0001277e main (main.m:16)

36  myApp                        0x00012734 start + 36



Thread 0 name:  Dispatch queue: com.apple.main-thread

Thread 0 Crashed:

0   libsystem_kernel.dylib        0x33e32350 __pthread_kill + 8

1   libsystem_c.dylib             0x376aefb2 pthread_kill + 54

2   libsystem_c.dylib             0x376eb366 abort + 90

3   libc++abi.dylib               0x3144cdda abort_message + 70

4   libc++abi.dylib               0x3144a094 default_terminate() + 20

5   libobjc.A.dylib               0x33b66a58 _objc_terminate() + 144

6   libc++abi.dylib               0x3144a118 safe_handler_caller(void (*)()) + 76

7   libc++abi.dylib               0x3144a1b0 std::terminate() + 16

8   libc++abi.dylib               0x3144b626 __cxa_rethrow + 90

9   libobjc.A.dylib               0x33b669b0 objc_exception_rethrow + 8

10  CoreFoundation                0x3657a29c CFRunLoopRunSpecific + 452

11  CoreFoundation                0x3657a0c4 CFRunLoopRunInMode + 100

12  GraphicsServices              0x36545336 GSEventRunModal + 70

13  UIKit                         0x30a20284 UIApplicationMain + 1116

14  myApp                        0x0001277e main (main.m:16)

15  myApp                        0x00012734 start + 36


Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager

Thread 1:

0   libsystem_kernel.dylib        0x33e225d0 kevent64 + 24

1   libdispatch.dylib             0x366c9d22 _dispatch_mgr_invoke + 806

2   libdispatch.dylib             0x366c5374 _dispatch_mgr_thread + 32


Thread 2:

0   libsystem_kernel.dylib        0x33e32d98 __workq_kernreturn + 8

1   libsystem_c.dylib             0x37686ad6 _pthread_workq_return + 14

2   libsystem_c.dylib             0x376867f2 _pthread_wqthread + 362

3   libsystem_c.dylib             0x37686680 start_wqthread + 4


Thread 3 name:  WebThread

Thread 3:

0   libsystem_kernel.dylib        0x33e21e30 mach_msg_trap + 20

1   libsystem_kernel.dylib        0x33e21fd0 mach_msg + 48

2   CoreFoundation                0x366082b6 __CFRunLoopServiceMachPort + 126

3   CoreFoundation                0x3660702c __CFRunLoopRun + 900

4   CoreFoundation                0x3657a238 CFRunLoopRunSpecific + 352

5   CoreFoundation                0x3657a0c4 CFRunLoopRunInMode + 100

6   WebCore                       0x3898aa58 RunWebThread(void*) + 440

7   libsystem_c.dylib             0x376910de _pthread_start + 306

8   libsystem_c.dylib             0x37690fa4 thread_start + 4


Thread 4:

0   libsystem_kernel.dylib        0x33e32d98 __workq_kernreturn + 8

1   libsystem_c.dylib             0x37686ad6 _pthread_workq_return + 14

2   libsystem_c.dylib             0x376867f2 _pthread_wqthread + 362

3   libsystem_c.dylib             0x37686680 start_wqthread + 4


Thread 5 name:  Dispatch queue: com.apple.CoreLocation.ConnectionClient.0x1d8a3f90.events

Thread 5:

0   libsystem_kernel.dylib        0x33e21e98 semaphore_timedwait_trap + 8

1   libdispatch.dylib             0x366c8c16 _dispatch_semaphore_wait_slow + 118

2   CoreLocation                  0x32b3a774 CLClientInvokeCallback(__CLClient*, CLClientEvent, objc_object*) + 340

3   CoreLocation                  0x32b3ddd8 ___CLClientCreateConnection_block_invoke_0 + 384

4   CoreLocation                  0x32b740b8 __setEventHandler_block_invoke_0 + 344

5   libxpc.dylib                  0x32457804 _xpc_connection_mach_event + 768

6   libdispatch.dylib             0x366ca688 _dispatch_mach_msg_invoke + 120

7   libdispatch.dylib             0x366c7afa _dispatch_queue_drain + 78

8   libdispatch.dylib             0x366ca92e _dispatch_mach_invoke + 166

9   libdispatch.dylib             0x366c7afa _dispatch_queue_drain + 78

10  libdispatch.dylib             0x366c5678 _dispatch_queue_invoke + 40

11  libdispatch.dylib             0x366c7afa _dispatch_queue_drain + 78

12  libdispatch.dylib             0x366c5678 _dispatch_queue_invoke + 40

13  libdispatch.dylib             0x366c8610 _dispatch_root_queue_drain + 208

14  libdispatch.dylib             0x366c87d4 _dispatch_worker_thread2 + 88

15  libsystem_c.dylib             0x376867ee _pthread_wqthread + 358

16  libsystem_c.dylib             0x37686680 start_wqthread + 4


Thread 0 crashed with ARM Thread State (32-bit):

    r0: 0x00000000    r1: 0x00000000      r2: 0x00000000      r3: 0x3ae97524

    r4: 0x00000006    r5: 0x3ae97b78      r6: 0x1cdb5a24      r7: 0x2fdf0a34

    r8: 0x1cdb5a00    r9: 0x00000300     r10: 0x00000000     r11: 0x00212bc4

    ip: 0x00000148    sp: 0x2fdf0a28      lr: 0x376aefb7      pc: 0x33e32350

  cpsr: 0x00000010

ELocation.m loadView :

- (void)loadView {

    _locationManager = [[CLLocationManager alloc] init];

    _locationManager.desiredAccuracy = kCLLocationAccuracyBest;

    _locationManager.delegate = self;

    [_locationManager startUpdatingLocation];

    _destLocation = nil;

    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:_locationManager.location.coordinate.latitude longitude:_locationManager.location.coordinate.longitude zoom:12]; //**line 45**

    mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];

    mapView.settings.zoomGestures = YES;

    mapView.settings.myLocationButton = YES;

    mapView.myLocationEnabled = YES;

    mapView.delegate = self;

    self.view = mapView;

}

2
你尝试过从应用商店下载并测试它,然后获取堆栈跟踪吗? - George Mitchell
你已经将调试 API 密钥更改为发布密钥了吗? - Laszlo
@GeorgeMitchell 是的,我已经编辑过了,请查看我的问题。 - u_kami
@TussLászló iOS有发布API密钥吗?我按照Google文档操作,但没有关于发布API密钥的说明。 - u_kami
2个回答

1
当你调用[_locationManager startUpdatingLocation]时,当位置可用时,稍后会异步通过locationManager:didUpdateLocations:回调。在那之前,_locationManager.location可能为空 - 尽管如果您的应用程序先前缓存了位置,则可能不为空。
这可能是您的应用程序崩溃的原因,对于那些以前没有运行过该应用程序的用户,因为在第45行,您假设有一个有效的位置来创建相机位置。虽然我不确定,因为在nil上调用.coordinate.latitude应该只返回0而不是崩溃。
可能是您的用户被提示访问其位置,并且在他们回答“是”之前尝试访问位置导致了崩溃。要在自己的设备上重现此问题,您需要重置位置和隐私设置。通过“设置”->“通用”->“重置”->“重置位置和隐私”进行此操作。不幸的是,这会将所有应用程序和隐私选项(例如位置、照片、联系人等)都重置。即使您删除然后重新安装您的应用程序,iOS也会记住您先前的回答。更简单的方法可能是尝试暂时更改捆绑标识符,但然后您还需要获取新的Google地图密钥。

谢谢,我成功解决了我的问题。看起来我忘记将CoreLocation.framework添加到我的项目中,尽管我不知道为什么在设备和模拟器的调试模式下没有它也可以工作。 - u_kami

0

请记住,此SDK适用于iOS 6.0及更高版本。崩溃可能发生在旧版iOS设备上吗?


是的,我知道我的部署目标是iOS 6.0。我在iOS 6和7上进行了测试,仍然崩溃。 - u_kami

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接