[CLOSED] SDKBOX IAP Android not compiling

Hi!
I’ve been trying to integrate the IAP plugin in cocos2dx in android with no success. iOS works like a charm of course, like always.

Details:

  • cocos2d-x 3.10
  • SDKBOX version 1.0.0.13
  • Trying to compile for android studio
  • NDK r10e

Android.mk:

LOCAL_PATH := $(call my-dir)
 
include $(CLEAR_VARS)
 
$(call import-add-path,$(LOCAL_PATH))
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos)
 
LOCAL_MODULE := cocos2dcpp_shared
 
LOCAL_MODULE_FILENAME := libcocos2dcpp
 
LOCAL_SRC_FILES := hellocpp/main.cpp \
...
 
LOCAL_CPPFLAGS := -DSDKBOX_ENABLED
 
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes \
...
 
# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END
 
LOCAL_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES := PluginIAP sdkbox
 
# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END
 
include $(BUILD_SHARED_LIBRARY)
 
$(call import-module, ./ sdkbox)
$(call import-module, ./pluginiap)
$(call import-module,.)
 
# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

Application.mk:

APP_STL := c++_shared
 
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
APP_LDFLAGS := -latomic
 
APP_PLATFORM := android-16
 
ifeq ($(NDK_DEBUG),1)
  APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
  APP_OPTIM := debug
else
  APP_CPPFLAGS += -DNDEBUG
  APP_OPTIM := release
endif

When I compile, I get this error

jni/../../../Classes/IAP/IAPHelper.cpp:55: error: undefined reference to 'sdkbox::IAP::purchase(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
jni/src/IAPProxy.cpp:49: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
jni/src/IAPProxy.cpp:47: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
/usr/local/Cellar/android-ndk/r10e/sources/cxx-stl/gnu-libstdc++/4.8/include/bits/stl_pair.h:96: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
jni/../../../../csc/protocols/share/json98.h:112: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/usr/local/Cellar/android-ndk/r10e/sources/cxx-stl/gnu-libstdc++/4.8/include/bits/stl_pair.h:96: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
jni/src/IAPProxy.cpp:25: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'

And so on and so forth…

Please help, this is very frustrating.

Thanks for your help

Made some progress.

I changed the APP_STL from

 c++_shared

to

 gnu_static

(as in the SDKbox example project) and now it compiles.
However, I now have another issue in Cocos2dxActivity.java.

import com.sdkbox.plugin.SDKBox; is not found

I have

PluginGooglePlay.jar
PluginIAP.jar
sdkbox.jar

in

projectdir/proj.android-studio/app/libs/

Should I move them?

Finally able to compile, now the game runs but it just shows a totally black screen, and I think it’s because of sdkbox.

The only console error is:

    06-29 19:34:17.741 21275-21303/com.davide.tiles W/System.err: java.lang.NoSuchMethodError: no static method with name='getDefaultTrackingMask' signature='()I' in class Lcom/sdkbox/plugin/TrackingInfoAndroid;
06-29 19:34:17.741 21275-21303/com.davide.tiles W/System.err:     at org.cocos2dx.lib.Cocos2dxRenderer.nativeInit(Native Method)
06-29 19:34:17.741 21275-21303/com.davide.tiles W/System.err:     at org.cocos2dx.lib.Cocos2dxRenderer.onSurfaceCreated(Cocos2dxRenderer.java:72)
06-29 19:34:17.741 21275-21303/com.davide.tiles W/System.err:     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1510)
06-29 19:34:17.741 21275-21303/com.davide.tiles W/System.err:     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1249)
06-29 19:34:17.741 21275-21303/com.davide.tiles E/SDKBOX_CORE: JNI_BRIDGE Not found static method getDefaultTrackingMask, for clazz com/sdkbox/plugin/TrackingInfoAndroid and signature ()I
06-29 19:34:17.751 21275-21303/com.davide.tiles W/dalvikvm: VFY: unable to resolve static method 16456: Lcom/google/android/gms/ads/identifier/AdvertisingIdClient;.getAdvertisingIdInfo (Landroid/content/Context;)Lcom/google/android/gms/ads/identifier/AdvertisingIdClient$Info;
06-29 19:34:17.751 21275-21321/com.davide.tiles E/TrackingInfo: reqAdvertisingIdentifier Error:java.lang.NoClassDefFoundError: com.google.android.gms.ads.identifier.AdvertisingIdClient

Any help?

can you change to APP_STL's value to gnustl_static and try to compile

sdkbox iap sample:

and i create a empty cocos2d-x v3.10 CPP project,
APP_STL in android-studio project also is gnustl_static

Hi! Thanks for the suggestion.

As stated in a previous post, I already changed that to gnustl_static and I was finally able to compile. Not having c++_shared limits me and I’ll have to change some code that currently uses ifstreams and so on, but whatever.

The problem I’m facing right now is that I am able to compile and run the game, but all I see is a BLACK SCREEN with this error:

    06-29 19:34:17.741 21275-21303/com.davide.tiles W/System.err: java.lang.NoSuchMethodError: no static method with name='getDefaultTrackingMask' signature='()I' in class Lcom/sdkbox/plugin/TrackingInfoAndroid;
06-29 19:34:17.741 21275-21303/com.davide.tiles W/System.err:     at org.cocos2dx.lib.Cocos2dxRenderer.nativeInit(Native Method)
06-29 19:34:17.741 21275-21303/com.davide.tiles W/System.err:     at org.cocos2dx.lib.Cocos2dxRenderer.onSurfaceCreated(Cocos2dxRenderer.java:72)
06-29 19:34:17.741 21275-21303/com.davide.tiles W/System.err:     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1510)
06-29 19:34:17.741 21275-21303/com.davide.tiles W/System.err:     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1249)
06-29 19:34:17.741 21275-21303/com.davide.tiles E/SDKBOX_CORE: JNI_BRIDGE Not found static method getDefaultTrackingMask, for clazz com/sdkbox/plugin/TrackingInfoAndroid and signature ()I
06-29 19:34:17.751 21275-21303/com.davide.tiles W/dalvikvm: VFY: unable to resolve static method 16456: Lcom/google/android/gms/ads/identifier/AdvertisingIdClient;.getAdvertisingIdInfo (Landroid/content/Context;)Lcom/google/android/gms/ads/identifier/AdvertisingIdClient$Info;
06-29 19:34:17.751 21275-21321/com.davide.tiles E/TrackingInfo: reqAdvertisingIdentifier Error:java.lang.NoClassDefFoundError: com.google.android.gms.ads.identifier.AdvertisingIdClient

I also tried to install the IAP sdkbox plugin in a brand new project, but it failed to do so for ANDROID STUDIO. It works fine for android (eclipse), but I need to use android studio, and from the sdkbox documentation it seems that android studio is supported, but it’s clearly not, at least from my experience.

Can somebody confirm this?

I’m closing this post and opening another one because it looks like the problem is the sdkbox does not support android studio (?) so that’s the root of all evil here.

i install iap to cocos2d-x v3.10 project, run fine.
here is my steps:

  1. create a cocos2d-x v3.10 cpp project by run cocos new IAPTest -l cpp -p com.sdkbox.test.IAPTest
  2. import iap to the empty project, by run sdkbox import iap
  3. run the empty project, by run cocos run -p android --android-studio
  4. the empty project work fine