4

My app was working before well, then i added admob framework and now its crashing .

Please check the crash logs,

enter image description here

i have tried in Google but there is no result regarding this crash.

If i commented the contents inside viewDidAppear() then app is working(not loading app part). But if am trying to load "admob" then its crashing.


Code:

-(void)viewDidAppear:(BOOL)animated{
    if([Connectivity hasConnectivity]){
        // [self loadAds];
        NSTimer* myTimer = [NSTimer scheduledTimerWithTimeInterval: 15.0 target: self
                                                          selector: @selector(callAfterSixtySecond:) userInfo: nil repeats: YES];
    }
}
-(void) callAfterSixtySecond:(NSTimer*) t
{
    
    if([GMMConnectivity hasConnectivity]){
        
        [self.adBanner removeFromSuperview];
        [self loadAdmob];
    }
}

-(void)loadAdmob{
    
    CGPoint origin;
    if(IS_RETINA){
        if([[UIScreen mainScreen] bounds].size.height >500){
            //        NSLog(@"5");
            origin = CGPointMake(0.0,
                                 568-
                                 CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).height);
        }else{
            //        NSLog(@"4");
            
            origin = CGPointMake(0.0,
                                 (480)-
                                 CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).height);
        }
    }else{
        //        NSLog(@"3");
        
        origin = CGPointMake(0.0,
                             (460)-
                             CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).height);
        
    }
    // Use predefined GADAdSize constants to define the GADBannerView.
    self.adBanner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait
                                                   origin:origin]
    ;
    
    // Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID
    // before compiling.
    self.adBanner.adUnitID = MY_BANNER_UNIT_ID;
    self.adBanner.delegate = self;
    [self.adBanner setRootViewController:self];
    [self.view addSubview:self.adBanner];
    self.adBanner.center =
    CGPointMake(self.view.center.x, self.adBanner.center.y);
    [self.adBanner loadRequest:[self createRequest]];
    [self.view addSubview:adBanner_];
}
Community
  • 1
  • 1
Bangalore
  • 1,572
  • 4
  • 20
  • 50

2 Answers2

34

You need to add "-ObjC" to Other Linker Flags of Build Settings tab. Good luck!

Pei
  • 11,452
  • 5
  • 41
  • 45
0

When you do:

[GADStaticDictionary decrementNumberForKey: shouldNotifyDelegate:];

The delegate is probably of type NSDecimalNumber, and this class doesn't implement a method called gad_negativeOne.

From the crash log, the problem is this. Now you should check your classes and understand what delegate are you setting, and where the gad_negativeOne method is.

Also because, a method with a prefix like this gad_ should be a private method.

Matteo Gobbi
  • 17,697
  • 3
  • 27
  • 41
  • Actually, prefixing is best practice for **category methods**. NSDecimalNumber already has two convenience methods for `one` and `zero`. It looks to me like they simply extended NSDecimalNumber with a another method to return a number with `-1`. – David Rönnqvist May 25 '14 at 10:11
  • and for private methods, because if you extend a class and implement some new methods, you could override a method which you don't see in the public interface. – Matteo Gobbi May 25 '14 at 10:13
  • but when i tried every google ad sdk,its crashing with same error – Bangalore May 25 '14 at 10:50