@victory144
I use cocos2d-x version 2.2.0. I have no file AppActivity.java, but I have file %my_project_name%.java. I do next things:
In %my_project_name%.java file I change package name from package org.cocos2dx.cpp; to %my_project_package_name% for example: package com.MyCompany.AwesomeGame;
In %my_project_name%.java file added next code
public class %my_project_name% extends Cocos2dxActivity
{
...
all code from your instructions
...
static
{
System.loadLibrary("cocos2dcpp");
}
}
In AdmobHelper.cpp I change path for classname
//In cocos2d-x version 3.0
const char* AppActivityClassName = "org/cocos2dx/cpp/AppActivity";
//In cocos2d-x version 2.2.0
const char* AppActivityClassName = "%my_project_package_name%";
That’s all, I hope it will be helpful for somebody.
@victory144
It will be cool, if you add in your instructions how to change addmob baner placement (to bottom for example).
Is it possible to show the Ad with sliding effect?
For instance, the Ad is hidden by default. After player wins the game, it will slide to correct position by calling showAd method.
@manelizzard
Unfortunately this decision didn’t help me. I understand that the library isn’t loaded, but I don’t understand why.
Yeah, I solved my problem. The problem was in distinction between 3.0 and 2.0 versions cocos2d-x. For version 2.0 at .java file has to be the following code
Hi victory144, I feel I am very close to solve this problem and this is thanks to you. I have implemented everything exactly as the tutorial shows, except for the AdHelper.cpp which has some modifications in my case, so I can handle ads on iOS also.
Well, my app is running but ads are not showing in android devices.
The problem I am struggling with now is that my LogCat shows, each X seconds (ad refresh time), this error msg:
06-26 15:30:12.203: I/Ads(14010): Starting ad request.
06-26 15:30:12.273: W/GooglePlayServicesUtil(14010): Google Play services is missing.
06-26 15:30:12.273: E/GooglePlayServicesUtil(14010): GooglePlayServices not available due to error 1
Oh mine, really thank you!. I finally solved the problem. It depends on the package name in src folder of the project., so (with cocos2d-x version 2.x.x )AppActivityClassName should be “com/someName/SomeName/projectName”. It took me almost a day!!
I’m pretty much using exactly this code, but it has the following problem:
If you click and ad and then go back to the game, clicking the back button closes the game.
I think it’s because the webview is catching the key input, instead of it being passed to cocos (key listener).
I followed the tutorial found on the Cocos2d-x wiki (http://www.cocos2d-x.org/wiki/User_Tutorial-Integrate_AdMob) that looks like the same content as this post. I got it working, so I can confirm that the tutorial is valid for this system/software config:
— Cocos2d-x rev. 3.2
— Google Play Services rev. 21
— Android 4.4.2 (API 19)
— Eclipse Luna Release (4.4.0)
— MacBook Pro 10.9.4
— Google Nexus 4 w/ Android 4.4.2
I encountered several speed bumps as I tried to get this to work. I hope this report saves someone a bit of aggravation. This is based on the wiki tutorial.
The following line in section 2.1 uses the wrong kind of hyphen/dash for one or more of the parameters. If you copy/paste from the tutorial at this location you will get an error when attempting to create your new project.
error:
cocos new admobTest –p com.test.admobTest –l cpp –d PROJECT_LOCATION
corrected:
cocos new admobTest -p com.test.admobTest -l cpp -d PROJECT_LOCATION
resulting error when compiling with build_native.py:
cocos new: error: argument -l/–language is required
Once I added the Google Play Services lib I got an error when building from Eclipse. I did a web search for whatever the error was and found instructions on changing the eclipse.ini settings to allocate a more memory to Eclipse.
After wrestling with the instructions for orienting ads at the bottom of the screen I pasted my final code into the thread on that topic. There are 2 possible solutions: http://cocos2d-x.org/forums/6/topics/53945
I encountered some kind of error when building from Eclipse that suggested that there was a conflict between the AndroidManifest.xml file located in the main project and the AndroidManifest.xml file in the Google Play Services lib. That problem eventually went away after I made several changes to Eclipse, but I’m not sure what ultimately fixed it:
— I updated a few of the item sin the Android SDK Manager
— I rebuilt the whole project from zero
I copied AdMobHelper.h/.cpp wholesale from the GigHub repository, but otherwise I tried to leave the default project unchanged and make only the necessary changes to the other files (HelloWorldScene.cpp, AppActivity.java, etc.)
I successfully integrated with com.google.android.gms.ads.*.
Ads works fine.
But I have a problem.
touch on the ads from admob, and then drag move to normal area of game screen, now pressing the back key will cause the app dissmiss(going to background?)
click on the ads and the view is switched to google play website, press the back key will return the game screen, now in the game screen press the back key again will also cause the app going to background
In both cases, when relaunch app, it crashes.
Does anyone suffer this?
Actually I’m trying to use AdSize.SMART_BANNER.
This smart banner doesn’t open any web site or something at the first touch.
Therefore, first touch Ads with smart banner case doesn’t fire onPause or onResume.
So, I tried to modify Cocos2dxGlSurfaceView.java to catch losing focus and set focus to surface view again.
The modified code worked what I expected - catch losing focus & set focus again -,
but unfortunately It didn’t fix my problem though fixed focus issue