Runtime error on SDKBOX

Runtime error on SDKBOX
0

Hello!
I’m trying to add SDKBOX + review + IAP to a new cocos2d-x v4.0 project. gradlew finishes successfully but on runtime it crashes with the following:

12-13 13:23:34.435 19699 19728 W System.err: java.lang.NoSuchMethodError: no static method “Lcom/sdkbox/plugin/SdkboxLog;.setDefaultDebugLevel(I)V”
12-13 13:23:34.436 19699 19728 W System.err: at com.sdkbox.plugin.SDKBox.nOnStart(Native Method)
12-13 13:23:34.436 19699 19728 W System.err: at com.sdkbox.plugin.SDKBox$a.run(SourceFile:1)
12-13 13:23:34.436 19699 19728 W System.err: at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1502)
12-13 13:23:34.436 19699 19728 W System.err: at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
12-13 13:23:34.436 19699 19728 E SDKBOX_CORE: JNI_BRIDGE Not found static method setDefaultDebugLevel, for clazz com/sdkbox/plugin/SdkboxLog and signature (I)V

12-13 13:23:36.587 19699 19728 E SDKBOX_CORE: JNI_BRIDGE Not found static method NewLog, for clazz com/sdkbox/plugin/SdkboxLog and signature (Ljava/lang/String;)V
12-13 13:23:36.587 19699 19728 E Review : : Failed to get plugin config json
12-13 13:23:36.587 19699 19728 E JniHelper: Classloader failed to find class of org.cocos2dx.cpp.Cocos2dxActivity
12-13 13:23:36.587 19699 19728 E JniHelper: Failed to find class org.cocos2dx.cpp.Cocos2dxActivity

12-13 13:23:39.568 19783 19783 F DEBUG : backtrace:
12-13 13:23:39.568 19783 19783 F DEBUG : #00 pc 0069e56e /data/app/com.monkeyibrow.worldcupsc-Q0hHbWPLjDBq-hZPvTxzJg==/lib/x86/libMyGame.so (sdkbox::ReviewProxy::tryShowDialog() const+30) (BuildId: 731cfb9bf32d80651dd1d2bb1122e0d04a276ff7)
12-13 13:23:39.568 19783 19783 F DEBUG : #01 pc 0069a52d /data/app/com.monkeyibrow.worldcupsc-Q0hHbWPLjDBq-hZPvTxzJg==/lib/x86/libMyGame.so (sdkbox::ReviewWrapperEnabled::tryToShowPrompt()+445) (BuildId: 731cfb9bf32d80651dd1d2bb1122e0d04a276ff7)

sdkbox.jar, PluginReview.jar are on \proj.android\app\libs

what else may be missing?

Thanks.

missing libsdkbox.a and so on.

plz ref to https://docs.sdkbox.com/en/qa/sdkbox-cmake/

Thanks,

unziped the APK, and you are right, the libsdkbox.a and others are not there.
However, I had this already on my cmakeLists.txt:

if(ANDROID)
add_definitions(-DSDKBOX_ENABLED)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/jni/PluginIAP/)
target_link_libraries(${APP_NAME} ext_PluginIAP)
add_definitions(-DSDKBOX_ENABLED)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/jni/PluginReview/)
target_link_libraries(${APP_NAME} ext_PluginReview)
add_definitions(-DSDKBOX_ENABLED)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/jni/PluginSdkboxPlay/)
target_link_libraries(${APP_NAME} ext_PluginSdkboxPlay)
add_definitions(-DSDKBOX_ENABLED)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/jni/sdkbox/)
target_link_libraries(${APP_NAME} ext_sdkbox)
endif()

for some reason the .A libs are not being packed.
any ideas? Thanks.

running gradlew --debug shows more info:

02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] evaluate library ext_sdkbox (x86)
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] not building target ext_sdkbox because it isn’t in targets set
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] evaluate library ext_unzip (x86)
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] not building target ext_unzip because it isn’t in targets set
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] evaluate library ext_md5 (x86)
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] not building target ext_md5 because it isn’t in targets set
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] evaluate library ext_png (x86)
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] not building target ext_png because it isn’t in targets set
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] evaluate library ext_curl (x86)
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] not building target ext_curl because it isn’t in targets set
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] evaluate library ext_box2d (x86)
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] not building target ext_box2d because it isn’t in targets set
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] evaluate library ext_PluginIAP (x86)
02:44:44.724 [INFO] [com.android.build.gradle.internal.cxx.logging.ErrorsAreFatalThreadLoggingEnvironment] not building target ext_PluginIAP because it isn’t in targets set

but now I don’t know what else to do.
I followed all the steps on SDKBOX config tutorial.

anyone? I’m super stuck… :frowning:

I tested v4 with admob.

0x01: CMakeLists.txt

add bellow codes to the end of file.

if(ANDROID)
    add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/jni/PluginAdMob)
    target_link_libraries(${APP_NAME} ext_PluginAdMob)

    add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/jni/sdkbox)
    target_link_libraries(${APP_NAME} ext_sdkbox)
endif()

0x02 AppActivity.java

//public class AppActivity extends Cocos2dxActivity {
public class AppActivity extends com.sdkbox.plugin.SDKBoxActivity {

0x03 gradle.properties

PROP_APP_ABI=armeabi-v7a

0x04 proj.android/app/build.gradle

add bellow code to the end

dependencies { compile 'com.google.android.gms:play-services-ads:17.2.0' }

0x05 proj.android/app/AndroidManifest.xml

<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-1329374026572143~7139010117" />

outout

2019-12-17 00:02:01.920 12291-12291/org.cocos2dx.cppv4 I/SDKBOX_CORE: Sdkbox Droid starting.
2019-12-17 00:02:01.920 12291-12291/org.cocos2dx.cppv4 I/SDKBOX_CORE: Sdkbox got VM.
2019-12-17 00:02:01.920 12291-12291/org.cocos2dx.cppv4 I/SDKBOX_CORE: Sdkbox jni initialized.
2019-12-17 00:02:01.922 12291-12291/org.cocos2dx.cppv4 D/SDKBOX_CORE: Loaded 0 tracking info _elements.

something is missing…

  • created a brand new cocos2d-x v4.0 project
  • donwloaded http://download.sdkbox.com/installer/v1/sdkbox-admob_v2.5.1.2.tar.gz
    • copied the libs folder to proj.android\app\libs (and removed android-support-v4.jar is we will be adding it with gradle)
    • copied the jni folder to proj.android\app\jni
  • changed the appActivity.java as instructed
  • on gradle.properties I’m building to x86, but that should make no difference as the x86 jni lib is on the jni folder
  • builds fine but crashes on load with:

12-16 18:46:35.111 14141 14141 E AndroidRuntime: java.lang.UnsatisfiedLinkError: No implementation found for void com.sdkbox.plugin.SDKBox.nativeInit(java.lang.Object, java.lang.ClassLoader) (tried Java_com_sdkbox_plugin_SDKBox_nativeInit and Java_com_sdkbox_plugin_SDKBox_nativeInit__Ljava_lang_Object_2Ljava_lang_ClassLoader_2)
12-16 18:46:35.111 14141 14141 E AndroidRuntime: at com.sdkbox.plugin.SDKBox.nativeInit(Native Method)

for some reason it looks the native lib is not being added…

is it possible that libsdkbox.a doesn’t match the NDK version I’m using and then the runtime can’t find the lib? What ndk version are you using?
I’m on r20b

$ echo $NDK_ROOT
/Users/admin/Documents/sdk/android/android-ndk-r16b

it’s not the NDK version either or the native platform armeabi-v7a.
I tried building to ndk n16b and to armeabi-v7a and crashes on device with the same error.

Looking at the CMake logs I see the libsdkbox.a appearing:
…\…\…\…\jni\sdkbox\libs_c++_static\armeabi-v7a\libsdkbox.a

but then it never shows up again in the logs, like these:

[645/647] Linking CXX static library engine\cocos\platform\libcpp_android_spec.a
[646/647] Linking CXX static library lib\libcocos2d.a
[647/647] Linking CXX shared library …\build\intermediates\cmake\debug\obj\armeabi-v7a\libMyGame.so

did you change anything on the proj.android/app/jni/sdkbox/CMakeLists.txt ?
what version of sdkbox are you using? is it different from the last available for admob, sdkbox-admob_v2.5.1.2.tar.gz ?
Can you please zip and share your working project based on cocos2d-x v4.0?
I can’t figure out what may be the issue.

plz try https://github.com/sdkbox/sdkbox-sample-cppv4

after almost one hour comparing my non-working project with yours (working), found out that I was missing the sdkbox::PluginAdMob::init(), which doesn’t seem very logic to me as the error was coming from the AppActivity initializer that is called way before this.
But looks like without the sdkbox reference on the cpp side, gradle doesn’t see the need to link the libsdkbox.a to the final package.

compiler will not link the sdkbox.a if project does not use any sdkbox api.