<Google> Invalid Request. Invalid ad width or height: (320, 0)
2018-12-12 21:03:48.819 Ball[9781:886199] adView:didFailToReceiveAdWithError: Request Error: Invalid ad request parameter(s). Check the Xcode console for details.
and when I hard code a value then the error will change to 'request error: no ad to show' even if i run it on my physical iPad that is (iOS 8.1) it will say "invalid ad width or height: (760, 0)"
So i created a regulor iOS project and copied the exact same code and then the ad showed on my iphone 5(9.1) and iPhone 5s simulator(iOS8.1) with no problem. this is easily reproducible its weird that in my cocos2d-x project the banner shows fine on iphoneXS simulator and iphone 6 simulator but not on iphone 5s(iOS 8.1) . but on a regular iOS project the banner shows fine on all the devices and simulators by the way I am using Xcode 10.1
if you create a brand new cocos2d-x project and just add this code you will be able to see what I am talking about
in AppController.h I do #import "GoogleMobileAds/GoogleMobileAds.h"
in AppController.mm I add [GADMobileAds configureWithApplicationID:@"ca-app-pub-3940256099942544~1458002511"]; to application didFinishLaunchingWithOptions
and in RootViewController.h I add @property(nonatomic, strong) GADBannerView *bannerView; to the interface
then in RootViewController.m I add the template code to viewDidLoad and add the methods
**I could send you both the Cocos2d-X and the regular iOS project that both have this exact same code implemented below and you can run it on iOS9 & iOS8(iphone5s and probably other ios8&ios9 simulators) so you can see what im talking about**
self.bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
[self addBannerViewToView:self.bannerView];
// Replace this ad unit ID with your own ad unit ID.
self.bannerView.adUnitID = @"ca-app-pub-3940256099942544/2934735716";
self.bannerView.rootViewController = self;
GADRequest *request = [GADRequest request];
[self.bannerView loadRequest:request];
#pragma mark - view positioning
-(void)addBannerViewToView:(UIView *_Nonnull)bannerView {
self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:self.bannerView];
if (@available(ios 11.0, *)) {
[self positionBannerViewAtBottomOfSafeArea:bannerView];
} else {
[self positionBannerViewAtBottomOfView:bannerView];
}
}
- (void)positionBannerViewAtBottomOfSafeArea:(UIView *_Nonnull)bannerView NS_AVAILABLE_IOS(11.0) {
// Position the banner. Stick it to the bottom of the Safe Area.
// Centered horizontally.
UILayoutGuide *guide = self.view.safeAreaLayoutGuide;
[NSLayoutConstraint activateConstraints:@[
[bannerView.centerXAnchor constraintEqualToAnchor:guide.centerXAnchor],
[bannerView.bottomAnchor constraintEqualToAnchor:guide.bottomAnchor]
]];
}
- (void)positionBannerViewAtBottomOfView:(UIView *_Nonnull)bannerView {
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeCenterX
multiplier:1
constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.bottomLayoutGuide
attribute:NSLayoutAttributeTop
multiplier:1
constant:0]];
}
@end
Hello I am using cocos2d-x to build my game and for specific reasons I do not want to use the C++ SDK for admob, I want to implement it specifically with CocoaPods iOS. I followed the tutorial here -> (https://developers.google.com/admob/ios/x-ad-rendering) and on my iPhone 6, 8 and XS the banner ad is showing , but if I test on iphone 5 (ios 9.0) or iphone 5/5s simulator(ios 8.1) it will tell me that<Google> Invalid Request. Invalid ad width or height: (320, 0)
2018-12-12 21:03:48.819 Ball[9781:886199] adView:didFailToReceiveAdWithError: Request Error: Invalid ad request parameter(s). Check the Xcode console for details.
and when I hard code a value then the error will change to 'request error: no ad to show'
So i created a regulor iOS project and copied the exact same code and then the ad showed on my iphone 5(9.1) and iPhone 5s simulator(iOS8.1) with no problem. this is easily reproducible its weird that in my cocos2d-x project the banner shows fine on iphoneXS simulator and iphone 6 simulator but not on iphone 5s(iOS 8.1) . but on a regular iOS project the banner shows fine on all the devices and simulators by the way I am using Xcode 10.1
if you create a brand new cocos2d-x project and just add this code you will be able to see what I am talking about
in AppController.h I do #import "GoogleMobileAds/GoogleMobileAds.h"
in AppController.mm I add [GADMobileAds configureWithApplicationID:@"ca-app-pub-3940256099942544~1458002511"]; to application didFinishLaunchingWithOptions
and in RootViewController.h I add @property(nonatomic, strong) GADBannerView *bannerView; to the interface
then in RootViewController.m I add the template code to viewDidLoad and add the methods
--
---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsubscrib...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-admob-ads-sdk/e6e53ee9-c417-4551-95a9-9cf580bdb57e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
- (void)positionBannerViewFullWidthAtBottomOfView:(UIView *_Nonnull)bannerView {
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
attribute:NSLayoutAttributeLeading
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeLeading
multiplier:1
constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:
bannerView
attribute:NSLayoutAttributeTrailing
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeTrailing
multiplier:1
constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.bottomLayoutGuide
attribute:NSLayoutAttributeTop
multiplier:1
constant:0]];
}
UPDATE: i followed this tutorial and now it is working weird
--
---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-admob-ads-sdk/519ed2b7-01e8-4caf-af0a-7ec5580b6350%40googlegroups.com.