现象:启动app的时候执行- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 里面的函数,当执行完[Fabric with:@[[Crashlytics class]]],应用闪退。console输出的错误信息是: uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: appID;显示调用了[LCRouter appURLForPath:appID:]。不知道LCRouter跟Fabric有什么关系,Fabric的运行会导致LCRouter发生Invalid parameter not satisfying: appID。
通过进一步的调试发现:LCRouter.m中的- (NSString *)appURLForPath:(NSString *)path appID:(NSString *)appID有时候会比 [AVOSCloud setApplicationId:LCCKAPPID clientKey:LCCKAPPKEY];先运行,导致appID=nil,引起闪退。有什么办法可以避免这种情况。
注:当我屏蔽掉[Fabric with:@[[Crashlytics class]]]后,错误就不出现了;
使用的机型是:iPhone7(iOS 12.1);
使用的sdk是:AVOSCloud (11.4.7)。Crashlytics (3.12.0)。
Console输出以下错误:
2018-12-06 10:06:03.113498+0800 CancerCureHelperDoctor1[6894:1588029] *** Assertion failure in -[LCRouter appURLForPath:appID:], /Users/zhengshaoling/Documents/newVersion/CancerCureHelperDoctor1/Pods/AVOSCloud/AVOS/AVOSCloud/Router/LCRouter.m:237
2018-12-06 10:06:03.114511+0800 CancerCureHelperDoctor1[6894:1588029] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: appID'
*** First throw call stack:
(0x212d73ea0 0x211f45a40 0x212c89c1c 0x213777140 0x1059d8d18 0x10588c0b8 0x10589426c 0x1058324b8 0x105828470 0x105827940 0x10582b5ac 0x103e6bc18 0x1069bf824 0x1069c0dc8 0x1069c3c90 0x1069d21dc 0x1069d2bc8 0x21299017c 0x212992cec)
libc++abi.dylib: terminating with uncaught exception of type NSException
附上代码段:
[Fabric with:@[[Crashlytics class]]];//当屏蔽了这句之后,错误不发生了。
// TODO: Move this to where you establish a user session
[self logUser];
[AVOSCloud setApplicationId:LCCKAPPID clientKey:LCCKAPPKEY];
[self registerForRemoteNotification];
附上截图: