Hello
I use Cocos helper to integrate Admob and my JS game. I follow the tutorial but when I run the command line “cocos compile -p android”. I got this error and libcocos2djs.so can not be buid.
In file included from jni/…/…/Classes/JNIResults.cpp:9:0:
jni/…/…/Classes/JNIResults.h:19:29: fatal error: SonarFrameworks.h: No such file or directory #include “SonarFrameworks.h”
@anieduard
I follow series of tutorial http://sonarsystems.co.uk/cocoshelper.php?platform=android, and according to the tutorial “Setup for Android” , I just copy JNIResults.cpp and JNIResults.h to Classes folder, no SonarFrameworks files, can you give me more detail. Thanks so much!
hello
I tried to add SonarFrameworks.cpp and SonarFrameworks.h as well as add them in Android.mk. But somethings wrong still occur and eventually libcocos2djs.so can not be built. Have u tried to integrate Admob on Android, please teach me. thanks
I tried, but still got this error:
"In file included from jni/…/…/Classes/JNIResults.cpp:9:0:
jni/…/…/Classes/JNIResults.h:19:47: fatal error: jni/…/…/Classes/SonarFrameworks.h: No such file or directory #include “jni/…/…/Classes/SonarFrameworks.h” "
Can you teach me step by step how to integrate Admob, thanks u so much!
thank so much for your help, I m trying, but how can I show or hide admob ads by JS code in my GameScene ?
Also, can you give me step-by-step how to build JS game on android device tutorial ?
thanks again
Follow the tutorial and add static AppActivity _AppActivity;
public class AppActivity extends Cocos2dxActivity{
static AppActivity _AppActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
_AppActivity = this;
}
public static void showAdMobBanner()
{
_AppActivity.runOnUiThread(new Runnable() {
@Override
public void run()
{
_adView.setVisibility(View.VISIBLE);
}
});
}
public static void hideAdMobBanner()
{
_AppActivity.runOnUiThread(new Runnable() {
@Override
public void run()
{
_adView.setVisibility(View.GONE);
}
});
}
In JS, you call the function with these
var ret = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "showAdMobBanner", "()V");
var ret = jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "hideAdMobBanner", "()V");
To build JS game on Android on Mac
I’m not sure the proper way to build, but since you ask, i just tell you how i build.
Create JS project with Cocos.
In Terminal, go to the project folder and use cocos compile -p android -m release to publish the apk. You need to create and specific where the keystore is. The apk can be found in publish folder.
You may need to use Google Closure Compiler to obfuscate your JS code.
you shouldn’t need SonarFrameworks.h for JS.
I see in my project that I’m not using it, it’s only for C++.
JNIResult is calling native JAVA api…
you must have src/sonar/systems folder with the files.