Can't run or compile game on Android because of Admob

I made my game in Xcode and it runs without any problems on iOS, I already released it on the App Store. But somehow it doesn’t work on Android, I tried compiling it with the command “cocos compile -s ~/path/to/game/ -p android” but I get the following error:

/Users/lukas/Documents/CocosGame/Classes/AppDelegate.cpp:27:10: fatal error: 'PluginAdMob/PluginAdMob.h' file not found
  #include "PluginAdMob/PluginAdMob.h"
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.

I also tried to run it in Android Studio but it didn’t work as well. So, I guess the problem has something to do with sdkbox/Admob or with importing the Admob Plugin for Android. But I did correctly include all my sdkbox Plugins in the Android.mk file, this is what it looks like:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := MyGame_shared

LOCAL_MODULE_FILENAME := libMyGame

LOCAL_SRC_FILES := \
$(LOCAL_PATH)/../../../Classes/AppDelegate.cpp \
# $(LOCAL_PATH)/hellocpp/main.cpp \
$(LOCAL_PATH)/../../../Classes/MenuScene.cpp \
all classes...

LOCAL_CPPFLAGS := -DSDKBOX_ENABLED \
-DSDKBOX_COCOS_CREATOR
LOCAL_LDLIBS := -landroid \
-llog
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes

# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END

LOCAL_WHOLE_STATIC_LIBRARIES += sdkbox
LOCAL_WHOLE_STATIC_LIBRARIES += PluginSdkboxAds
LOCAL_WHOLE_STATIC_LIBRARIES += PluginAdMob
LOCAL_WHOLE_STATIC_LIBRARIES += PluginShare
LOCAL_WHOLE_STATIC_LIBRARIES += PluginSdkboxPlay

LOCAL_STATIC_LIBRARIES := cc_static

# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END

include $(BUILD_SHARED_LIBRARY)
$(call import-add-path, $(LOCAL_PATH))

$(call import-module, cocos)
$(call import-module, ./sdkbox)
$(call import-module, ./PluginSdkboxAds)
$(call import-module, ./PluginAdmob)
$(call import-module, ./PluginShare)
$(call import-module, ./PluginSdkboxPlay)

# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

I really don’t know what i’m missing here can someone help me?

plz check the file proj.android/app/jni/PluginAdmob/PluginAdMob.h exists.

Yes it exists, and the other Plugins too.

/Users/admin/test/cpp317/proj.android/app/jni/../../../Classes/AppDelegate.cpp:31:10: warning: non-portable path to file '"PluginAdmob/PluginAdMob.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path]
#include "PluginAdMob/PluginAdMob.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
         "PluginAdMob/PluginAdMob.h"

it’s a warning on my side.

plz change

#include "PluginAdMob/PluginAdMob.h"

to

#include "PluginAdmob/PluginAdMob.h"

Anything else that could help?

chang #include "PluginAdMob/PluginAdMob.h" to #include "PluginAdmob/PluginAdMob.h"

no help?

I‘m not at home right now, I will try it when im back. Thanks for the help

Ok, I tried it out now but I still get the same error:

  /Users/lukas/Documents/CocosGame/Classes/AppDelegate.cpp:27:10: fatal error: 'PluginAdmob/PluginAdMob.h' file not found
  #include "PluginAdmob/PluginAdMob.h"
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.

But the file “/Users/lukas/Documents/CocosGame/proj.android/app/jni/PluginAdmob/PluginAdMob.h” exists, I don’t understand why I get this error.

try #include "/Users/lukas/Documents/CocosGame/proj.android/app/jni/PluginAdmob/PluginAdMob.h"

I changed all Plugin imports to Absolute paths now, like this:

#include "/Users/lukas/Documents/CocosGame/proj.android/app/jni/PluginAdmob/PluginAdMob.h"
#include "/Users/lukas/Documents/CocosGame/proj.android/app/jni/PluginShare/PluginShare.h"
#include "/Users/lukas/Documents/CocosGame/proj.android/app/jni/PluginSdkboxPlay/PluginSdkboxPlay.h"

but now i get the following error when I try to compile the the project using “cocos compile…”:

ibext_pvmp3dec.a lib/libext_tremolo.a ../../../../../../cocos2d/external/zlib/prebuilt/android/x86/libz.a lib/libext_unzip.a -lGLESv2 -lEGL -llog -landroid -lOpenSLES -latomic -lm && :
  /Users/lukas/Documents/CocosGame/Classes/AppDelegate.cpp:94: error: undefined reference to 'sdkbox::PluginAdMob::init()'
  /Users/lukas/Documents/CocosGame/Classes/AppDelegate.cpp:95: error: undefined reference to 'sdkbox::PluginShare::init(char const*)'
  /Users/lukas/Documents/CocosGame/Classes/AppDelegate.cpp:96: error: undefined reference to 'sdkbox::PluginSdkboxPlay::init()'
  /Users/lukas/Documents/CocosGame/Classes/AppDelegate.cpp:97: error: undefined reference to 'sdkbox::PluginSdkboxPlay::signin(bool)'
  /Users/lukas/Documents/CocosGame/Classes/AppDelegate.cpp:126: error: undefined reference to 'MenuScene::createScene()'
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.

But when I try to run it in Android Studio I only get this error:

/Users/lukas/Documents/CocosGame/proj.android/app/jni/../../../Classes/AppDelegate.cpp:126: error: undefined reference to 'MenuScene::createScene()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/lukas/Documents/CocosGame/proj.android/app/build/intermediates/ndkBuild/debug/obj/local/x86/libMyGame.so] Error 1

whats your Android.mk

$(call import-module, ./PluginAdMob)

or

$(call import-module, ./PluginAdmob)

You can see my full Android.mk file in my Post at the top. It’s
$(call import-module, ./PluginAdmob)

plz try change LOCAL_WHOLE_STATIC_LIBRARIES += PluginAdMob ==>
LOCAL_WHOLE_STATIC_LIBRARIES += PluginAdmob

Still not working, now I get this error:
/Users/lukas/Library/Android/sdk/ndk-bundle/build/core/build-binary.mk:666: Android NDK: Module MyGame_shared depends on undefined modules: PluginAdmob

so plz revert it back .

I do not know how to solve this issue.

Are there some folders or files that are PluginAdMob/PluginAdmob .

plz check them by yourself.

my filesystem is Case insensitive.

Can you give me an example project with working Admob so I can test it on my pc?

http://docs.sdkbox.com/en/plugins/admob/#sample-project

I downloaded the project but when I run “cocos run -p android” I get the following error:

Traceback (most recent call last):
  File "/Applications/Development/cocos2d-x/tools/cocos2d-console/bin/cocos.py", line 1081, in <module>
    run_plugin(command, argv, plugins)
  File "/Applications/Development/cocos2d-x/tools/cocos2d-console/bin/cocos.py", line 967, in run_plugin
    dep_name, argv, plugins)
  File "/Applications/Development/cocos2d-x/tools/cocos2d-console/bin/cocos.py", line 967, in run_plugin
    dep_name, argv, plugins)
  File "/Applications/Development/cocos2d-x/tools/cocos2d-console/bin/cocos.py", line 970, in run_plugin
    plugin.run(argv, dependencies_objects)
  File "/Applications/Development/cocos2d-x/tools/cocos2d-console/plugins/plugin_compile/project_compile.py", line 1523, in run
    self.build_android()
  File "/Applications/Development/cocos2d-x/tools/cocos2d-console/plugins/plugin_compile/project_compile.py", line 478, in build_android
    self.app_abi, gradle_support_ndk)
UnboundLocalError: local variable 'gradle_support_ndk' referenced before assignment

Does it work for you and how can i fix this?

yes, I build it everyday.

the example is base on cocos2d-x 3.8.1

env requirement:

  1. NDK r10d
  2. cocos console 3.8.1

When i run “cocos -v” I get the following output:

Python 2.7.10
cocos2d-x-3.17.1
Cocos Console 2.3

How can I update my cocos console? and how can I fix the bug I posted before?