Let me ask @nite to help us out with this.
Can you print the products and see what it contains?
cc.log(products)
If I try to access anything from products parameter, the game will automatically close. But sometime I can print the length of products
This is how I implement in Cocos2dxActivity.java:
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CocosPlayClient.init(this, false);
onLoadNativeLibraries();
SDKBox.init(this);
sContext = this;
this.mHandler = new Cocos2dxHandler(this);
Cocos2dxHelper.init(this);
this.mGLContextAttrs = getGLContextAttrs();
this.init();
if (mVideoHelper == null) {
mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout);
}
if(mWebViewHelper == null){
mWebViewHelper = new Cocos2dxWebViewHelper(mFrameLayout);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if(!SDKBox.onActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
for (OnActivityResultListener listener : Cocos2dxHelper.getOnActivityResultListeners()) {
listener.onActivityResult(requestCode, resultCode, data);
}
super.onActivityResult(requestCode, resultCode, data);
}
@Override
protected void onStart() {
super.onStart();
SDKBox.onStart();
}
@Override
protected void onStop() {
super.onStop();
SDKBox.onStop();
}
@Override
protected void onResume() {
super.onResume();
SDKBox.onResume();
Cocos2dxHelper.onResume();
this.mGLSurfaceView.onResume();
}
@Override
protected void onPause() {
super.onPause();
SDKBox.onPause();
Cocos2dxHelper.onPause();
this.mGLSurfaceView.onPause();
}
@Override
public void onBackPressed(){
if(!SDKBox.onBackPressed()){
super.onBackPressed();
}
}
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
$(call import-add-path,$(LOCAL_PATH))
LOCAL_MODULE := cocos2djs_shared
LOCAL_MODULE_FILENAME := libcocos2djs
LOCAL_SRC_FILES := \
../../Classes/protobuf-lite/google/protobuf/io/coded_stream.cc \
../../Classes/protobuf-lite/google/protobuf/stubs/common.cc \
../../Classes/protobuf-lite/google/protobuf/extension_set.cc \
../../Classes/protobuf-lite/google/protobuf/generated_message_util.cc \
../../Classes/protobuf-lite/google/protobuf/message_lite.cc \
../../Classes/protobuf-lite/google/protobuf/stubs/once.cc \
../../Classes/protobuf-lite/google/protobuf/stubs/atomicops_internals_x86_gcc.cc \
../../Classes/protobuf-lite/google/protobuf/repeated_field.cc \
../../Classes/protobuf-lite/google/protobuf/wire_format_lite.cc \
../../Classes/protobuf-lite/google/protobuf/io/zero_copy_stream.cc \
../../Classes/protobuf-lite/google/protobuf/io/zero_copy_stream_impl_lite.cc \
../../Classes/protobuf-lite/google/protobuf/stubs/stringprintf.cc \
../../Classes/runtime/ConnectWaitLayer.cpp \
../../Classes/runtime/ConsoleCommand.cpp \
../../Classes/runtime/FileServer.cpp \
../../Classes/runtime/Landscape_png.cpp \
../../Classes/runtime/PlayDisable_png.cpp \
../../Classes/runtime/PlayEnable_png.cpp \
../../Classes/runtime/Portrait_png.cpp \
../../Classes/runtime/Protos.pb.cc \
../../Classes/runtime/Runtime.cpp \
../../Classes/runtime/Shine_png.cpp \
../../Classes/VisibleRect.cpp \
../../Classes/PluginIAPJS.cpp \
../../Classes/PluginIAPJSHelper.cpp \
../../Classes/SDKBoxJSHelper.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/ConfigParser.cpp \
hellojavascript/Runtime_android.cpp \
hellojavascript/main.cpp
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../../Classes/protobuf-lite \
$(LOCAL_PATH)/../../Classes/runtime \
$(LOCAL_PATH)/../../Classes
LOCAL_STATIC_LIBRARIES := cocos_jsb_static
LOCAL_STATIC_LIBRARIES += PluginIAP
LOCAL_STATIC_LIBRARIES += sdkbox
LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT
include $(BUILD_SHARED_LIBRARY)
$(call import-module, ./sdkbox)
$(call import-module, ./pluginiap)
$(call import-module,bindings)
And I init the sdkbox like this:
sdkbox.IAP.init();
sdkbox.IAP.setListener(game.iap);
This is the class I create for listener:
game.IAPListener = cc.Class.extend({
ctor: function(){
ccui.Widget.prototype.ctor.call(this);
this.init();
},
init: function(){
if (ccui.Widget.prototype.init.call(this)){
return true;
}
return false;
},
onSuccess : function (product) {
game.gameController.onProductBoughtSuccess(product.id);
},
onFailure : function (product, msg) {
},
onCanceled : function (product) {
},
onRestored : function (product) {
},
onProductRequestSuccess : function (products) {
cc.log("IAPController.js:29 - SUCCESS");
cc.log(products);
scene.PremiumShop._getInstance().updateList(products);
},
onProductRequestFailure : function (msg) {
//When product refresh request fails.
cc.log("IAPController.js:37 \n" +
"msg = " + msg + " / "
);
}
});
game.IAPListener.instance = null;
game.IAPListener._getInstance = function(){
if(game.IAPListener.instance == null){
game.IAPListener.instance = new game.IAPListener();
}
return game.IAPListener.instance;
};
game.iap = game.IAPListener._getInstance();
Please let me know if I has some error somewhere thanks you so much @nite
Recently, I update the sdk to version 1.2.0.
Re-run my game again, rarely it can print out all the object it got on the server on first time I built it. But in the second time it automatic stop the app without anythings output.
I caught some error in the logcat like this:
E/sdkbox (18498): getFingerprintString(build): 0♣0♠0☺0♦0♠0♣0♣0☻0♦0
E/sdkbox (18498): getFingerprintString(androidid): ef28ab5cfda2cfd6
E/sdkbox (18498): getFingerprintString(macaddress): 50:3c:c4:5a:09:bb
This error occurs after sdk.IAP.init() execute
and then…
F/libc (18498): Fatal signal 11 (SIGSEGV) at 0x00000030 (code=1), thread 18498 (.lina.opposite2)
F/libc (18498): Send stop signal to pid:18498 in debugger_signal_handler
E/AnalyticsTracker(16343): Each length of parameters value should less than 128 character, or will be CUT
E/Trace (19976): error opening trace file: No such file or directory (2)
E/linker (19976): load_library(linker.cpp:759): library “libmaliinstr.so” not found
AND THIS ON OTHER DEVICES:
E/sdkbox (31184): getFingerprintString(build): 000☺0♦0♠0☻0♦0♥
E/sdkbox (31184): getFingerprintString(androidid): dbd2446189b7a9a7
E/sdkbox (31184): getFingerprintString(macaddress): A8:7C:01:BB:06:4F
F/libc (31184): Fatal signal 11 (SIGSEGV) at 0x00000030 (code=1), thread 31184 (.lina.opposite2)
E/MediaPlayer-JNI(31184): QCMediaPlayer mediaplayer NOT present
E/tmiMPEG2TSExtractor( 245): SnifftmiMPEG2TS @LINE=1372
E/MediaPlayerService( 245): WFD client is not created
E/audio_hw_primary( 245): ERROR: Unable to get time stamp from compress driver
E/ ( 245): Request requires android.permission.MODIFY_AUDIO_SETTINGS
E/audio_hw_primary( 245): ERROR: Unable to get time stamp from compress driver
E/ ( 245): [NXP] tfaRunIsCold:0x001d
E/ ( 245): [NXP] tfaRunIsCold:0x001d
E/android.os.Debug( 765): !@Dumpstate > dumpstate -k -t -z -d -o /data/log/dumpstate_app_error
E/SMD ( 237): DCD OFF
E/Watchdog( 765): !@Sync 1535
I’ll try your setup and see if I can make it work.
Thanks, I’m waiting in every second for your solution
Confirmed it’s a bug, still working on it.
It could be a cocos2d-js 3.6 issue, working with cocos2d-js developer to figure it out.
Sadly, can I try sdkbox 1.2.0.1 with cocos2d-js 3.7? Not sure it’ll work
We found the issue, should be able to fix it by tomorrow.
Wow, your team is so great. I’ll wait for the solution
This bug has been fixed, if you can’t wait for the next release, you can tested it out using nightly build
sdkbox import iap --staging
Best thanks for you,
Can that command be overrided in the imported iap project?
It’s work perfect now
Hello,
I see the same error logs when I call sdkbox.IAP.init(); in the JS (I only call this for now).
08-03 21:59:15.838: E/sdkbox(2152): getFingerprintString(build): 0a0a00a0a0��0��0 00
08-03 21:59:15.858: E/sdkbox(2152): getFingerprintString(androidid): a892587c8a2a7cab
08-03 21:59:15.889: E/sdkbox(2152): getFingerprintString(macaddress): null
(I’m running this on a simulator, but a real device gives me the same result)
I’m using the last IAP nightly build. Here is my version info:
Cocos2D-X v3.7 (JS)
Android 4.2.2
SDKBox IAP v1.2.1.3 (crashed also in v1.2.1.0)
My Cocos2dxActivity.java has been modified through the new diff file you provided (nice!), I also double-checked with the tuto, it seems to be fine.
That’s a mistake, not actually an error log, besides the log, did the IAP work for you?