** Skip to the bottom of this question to find the problem / solution **
I just finished converting my app from GA 2.0 to 3.0. Part of that conversion includes the incorporation of GAIDictionaryBuilder
. The app is running but it soon crashes after launch. Here is the xcode log from start to crash. More notes at the bottom.
2014-11-06 20:43:16.402 xxxxx[17769:2433378] VERBOSE: GoogleAnalytics 3.10 +[GAITrackerModel initialize] (GAITrackerModel.m:88): idfa class missing, won't collect idfa
[Allocator] Middle guard protection failed %d
[Allocator] Allocator invalid, falling back to malloc
2014-11-06 20:43:16.467 xxxxx[17769:2433378] bundle id: com.xxxxx.iphone-app
2014-11-06 20:43:16.523 xxxxx[17769:2433378] The internet is working via WWAN.
2014-11-06 20:43:16.524 xxxxx[17769:2433378] A gateway to the host server is working via WWAN.
2014-11-06 20:43:16.525 xxxxx[17769:2433430] Reachability: WR -t-----
2014-11-06 20:43:17.091 xxxxx[17769:2433378] INFO: GoogleAnalytics 3.10 -[GAIReachabilityChecker reachabilityFlagsChanged:] (GAIReachabilityChecker.m:159): Reachability flags update: 0X040003
2014-11-06 20:43:17.091 xxxxx[17769:2433378] The internet is working via WWAN.
2014-11-06 20:43:17.092 xxxxx[17769:2433378] A gateway to the host server is working via WWAN.
2014-11-06 20:43:17.133 xxxxx[17769:2433378] registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.
2014-11-06 20:43:17.152 xxxxx[17769:2433378] CACHE CHECK: messages.cached.xml, 2014-11-07 02:43:17 +0000, 2014-11-07 03:16:25 +0000, -1, -1, 1
2014-11-06 20:43:17.152 xxxxx[17769:2433378] Loading from archive messages.cached.xml
2014-11-06 20:43:17.156 xxxxx[17769:2433378] CACHE CHECK: featured.cached.xml, 2014-11-06 18:30:00 +0000, 2014-11-07 01:56:14 +0000, -1, -1, 1
2014-11-06 20:43:17.157 xxxxx[17769:2433378] Loading from archive featured.cached.xml
2014-11-06 20:43:17.203 xxxxx[17769:2433428] VERBOSE: GoogleAnalytics 3.10 -[GAIBatchingDispatcher persist:] (GAIBatchingDispatcher.m:497): Saved hit: {
parameters = {
"&_crc" = 0;
"&_u" = ".xxxxx";
"&_v" = "mi3.1.0";
"&a" = xxxxx;
"&aid" = "com.xxxxx.iphone-app";
"&an" = xxxxx;
"&av" = "2.0";
"&cd" = "/featured";
"&cid" = "xxxxx";
"&ds" = app;
"&sr" = 320x568;
"&t" = screenview;
"&tid" = "xxxxx";
"&ul" = en;
"&v" = 1;
"&z" = xxxxx;
gaiVersion = "3.10";
useSecure = 0;
};
timestamp = "2014-11-07 03:43:17 +0000";
}
2014-11-06 20:43:17.221 xxxxx[17769:2433378] setActiveContent title: (null)
2014-11-06 20:43:17.331 xxxxx[17769:2433378] Loading from archive 80.cached.jpg
2014-11-06 20:43:17.336 xxxxx[17769:2433378] Loading from archive 64.cached.jpg
2014-11-06 20:43:17.343 xxxxx[17769:2433378] Loading from archive 74.cached.jpg
2014-11-06 20:43:17.347 xxxxx[17769:2433378] Loading from archive 59.cached.jpg
2014-11-06 20:43:17.355 xxxxx[17769:2433378] Loading from archive 57.cached.jpg
2014-11-06 20:43:17.494 xxxxx[17769:2433378] -[GAIDictionaryBuilder objectForKey:]: unrecognized selector sent to instance 0x17027b340
2014-11-06 20:43:17.502 xxxxx[17769:2433378] WARNING: GoogleAnalytics 3.10 void GAIUncaughtExceptionHandler(NSException *) (GAIUncaughtExceptionHandler.m:49): Uncaught exception: -[GAIDictionaryBuilder objectForKey:]: unrecognized selector sent to instance 0x17027b340
2014-11-06 20:43:17.560 xxxxx[17769:2433428] VERBOSE: GoogleAnalytics 3.10 -[GAIBatchingDispatcher persist:] (GAIBatchingDispatcher.m:497): Saved hit: {
parameters = {
"&_crc" = 0;
"&_u" = ".oyLo";
"&_v" = "mi3.1.0";
"&a" = xxxxx;
"&aid" = "com.xxxxx.iphone-app";
"&an" = xxxxx;
"&av" = "2.0";
"&cd" = "/featured";
"&cid" = "xxxxx";
"&ds" = app;
"&exd" = "NSInvalidArgumentException\nTrace:\n<redacted>\n<redacted>\n_CF_forwarding_prep_0\n-[GAITrackerImpl gai_send:]\n-[AppDelegate applicationDidBecomeActive:]\n<";
"&exf" = 1;
"&sr" = 320x568;
"&t" = exception;
"&tid" = "xxxxx";
"&ul" = en;
"&v" = 1;
"&z" = xxxxx;
gaiVersion = "3.10";
useSecure = 0;
};
timestamp = "2014-11-07 03:43:17 +0000";
}
2014-11-06 20:43:17.605 xxxxx[17769:2433428] VERBOSE: GoogleAnalytics 3.10 -[GAIRequestBuilder requestPostUrl:payload:compression:] (GAIRequestBuilder.m:167): building URLRequest for http://www.google-analytics.com/batch
2014-11-06 20:43:17.607 xxxxx[17769:2433428] VERBOSE: GoogleAnalytics 3.10 -[GAIBatchingDispatcher dispatchWithCompletionHandler:] (GAIBatchingDispatcher.m:612): Sending hit(s) POST: http://www.google-analytics.com/batch
2014-11-06 20:43:17.807 xxxxx[17769:2433378] INFO: GoogleAnalytics 3.10 -[GAIBatchingDispatcher didSendHits:response:data:error:] (GAIBatchingDispatcher.m:208): Hit(s) dispatched: HTTP status 200
2014-11-06 20:43:17.808 xxxxx[17769:2433428] INFO: GoogleAnalytics 3.10 -[GAIBatchingDispatcher deleteHits:] (GAIBatchingDispatcher.m:509): hit(s) Successfully deleted
2014-11-06 20:43:17.811 xxxxx[17769:2433428] INFO: GoogleAnalytics 3.10 -[GAIBatchingDispatcher didSendHits:] (GAIBatchingDispatcher.m:219): 2 hit(s) sent
2014-11-06 20:43:20.093 xxxxx[17769:2433378] Login response: true
2014-11-06 20:43:20.094 xxxxx[17769:2433378] auto login check: GOOD
2014-11-06 20:43:22.548 xxxxx[17769:2433378] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GAIDictionaryBuilder objectForKey:]: unrecognized selector sent to instance 0x17027b340'
*** First throw call stack:
(0x184189e48 0x19487c0e4 0x184190f14 0x18418dcc4 0x184092c1c 0x10023d314 0x1000ad71c 0x1889ba488 0x188bcb818 0x18c3ed640 0x184142124 0x18414122c 0x18413f850 0x18406d1f4 0x18d2035a4 0x18899e784 0x10014cac4 0x194eeaa08)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I get that the crash is happening because there's an unrecognized selector used with GAIDictionaryBuilder
somewhere but where's the location? I am using the GAIDictionaryBuilder
all over and the usage is always the same. Any suggestions for my next troubleshooting move?
[[[GAI sharedInstance] defaultTracker] send:[GAIDictionaryBuilder createEventWithCategory:@"General"
action:@"App Became Active"
label:nil
value:0]];
I needed to add build
to the GAIDictionaryBuilder
[[[GAI sharedInstance] defaultTracker] send:[[GAIDictionaryBuilder createEventWithCategory:@"General"
action:@"App Became Active"
label:nil
value:0] build]];
Try adding an exceptions breakpoint first.
You can also try using some @try @catch blocks and try to catch the error (maybe catch a centralized method you use inside your code - if any).
Also, when inside your code, you can first ask yourself if the method you are trying to access by using respondsToSelector:
These are from the top of my head. I'll try to get back with updates if you provide further information.