Solution for cocos2dx and AdMob not displayed

Source: Internet
Author: User
Tags admob

Cocos2dx2.2.3 add admod according to official documents. Start the application and display "ad finished loading" in the eclipse log, but no advertisement is displayed on the interface,

It can only be displayed when the screen is re-lit after the screen is locked.

The Google solution is as follows:

1   adView.loadAd(adRequest);2   adView.setBackgroundColor(Color.BLACK);3   addContentView(adView,adParams);4   adView.setBackgroundColor(0);

In addition, VPN is required to test AdMob in mainland China. Otherwise, advertisements may not be displayed.

Reference URL:

Http://discuss.cocos2d-x.org/t/cocos2dxglsurfaceview-hide-my-addview-withusing-admob-for-android-device/11458/6

Http://stackoverflow.com/questions/22277904/adview-not-appear-in-android-cocos2dx

Excerpt:

 

Ymkimwizard18 Feb

Hello everyone.
I'll try to display AdMob on Android device.
Curiously, when I run my game. First time, I can't see addview screen.
But lock and unlock, if I come back my game. Then I can see addview without any problem.
I'm searching your code snip.
But I don't find correct answoer.
This just my own isseu? Kindly can you check my source code.
Why, first time, I can't see AdMob screen.

 

 

Ymkimwizard23 Feb

Hello.
I found solution. This is not JNI issue.
Simpley, this is come from AdMob with using Google Play service.
For solving this issue, I just add below line

Adview. loadad (adrequest );
Adview. setbackgroundcolor (color. Black );
Addcontentview (adview, adparams );

Then without any problem, from application starting, I can see AdMob view.
Thanks.

If you need further infomation can you refer below
Http://stackoverflow.com/questions/17975659/how-to-duplicate-sprite-of-sprites-in-cocos2d-x-2-1-44

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.