[FIXED] SDKBOX IAP Plugin crash

Hi,

I’m trying to integrate SDKBOX IAPs in my project, I followed the installation guide and it compiles well.
But when the game starts it crashes.

Here is the crash log:

E/AndroidRuntime(13630): java.lang.UnsatisfiedLinkError: No implementation found for void com.sdkbox.plugin.SDKBox.nativeSetAssetManager(android.content.Context, android.content.res.AssetManager) (tried Java_com_sdkbox_plugin_SDKBox_nativeSetAssetManager and Java_com_sdkbox_plugin_SDKBox_nativeSetAssetManager__Landroid_content_Context_2Landroid_content_res_AssetManager_2) E/AndroidRuntime(13630): at com.sdkbox.plugin.SDKBox.nativeSetAssetManager(Native Method) E/AndroidRuntime(13630): at com.sdkbox.plugin.SDKBox.init(SDKBox.java:61) E/AndroidRuntime(13630): at org.cocos2dx.cpp.AppActivity.onCreate(AppActivity.java:40) E/AndroidRuntime(13630): at android.app.Activity.performCreate(Activity.java:5990) E/AndroidRuntime(13630): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) E/AndroidRuntime(13630): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) E/AndroidRuntime(13630): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) E/AndroidRuntime(13630): at android.app.ActivityThread.access$800(ActivityThread.java:151) E/AndroidRuntime(13630): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) E/AndroidRuntime(13630): at android.os.Handler.dispatchMessage(Handler.java:102) E/AndroidRuntime(13630): at android.os.Looper.loop(Looper.java:135) E/AndroidRuntime(13630): at android.app.ActivityThread.main(ActivityThread.java:5254) E/AndroidRuntime(13630): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(13630): at java.lang.reflect.Method.invoke(Method.java:372) E/AndroidRuntime(13630): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) E/AndroidRuntime(13630): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Android: 5.1.1
Cocos2d-x: 3.6 (cpp)
SDKBOX: 1.1.5

How can I resolve this?

Thanks,

What do you have in your Cocos2dxActivity.java?

Currently Cocos2dxActivity.java isn’t modified.

This is the AppActivity.java file:

package org.cocos2dx.cpp;

import org.cocos2dx.lib.Cocos2dxActivity;
import com.sdkbox.plugin.SDKBox;

import android.content.Intent;
import android.os.Bundle;

public class AppActivity extends Cocos2dxActivity {

	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		SDKBox.init(this);
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if(!SDKBox.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();
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		SDKBox.onPause();
	}
	
	@Override
	public void onBackPressed() {
		if(!SDKBox.onBackPressed()) {
			super.onBackPressed();
		}
	}
}

All the sdkbox files (jni and libs) are in proj.android folder.

Previously, I tried modifying the Cocos2dxActivity.java and had the same result.

I get the exact same error. If I used version 1.1.3 everything works. When I upgrade to version 1.1.5 I get the error message joh gets “No implementation found for native Lcom/sdkbox/plugin/SDKBox”. All I did between version 1.1.3 and 1.1.5 is replace “import org.cocos2dx.plugin.PluginWrapper;” with “import com.sdkbox.plugin.SDKBox;” and the references “PluginWrapper.X” with “SDKBox.X”. The folders jni and lib were copied to my local copy. Cleaning and rebuilds do not help. The application crashes on this line “SDKBox.init(this);”. I am sticking with version 1.1.3 for now.

Also, my setup is just like joh too, I have Android 5.1.1 Nexus 7 2013, with Cocos2Dx 3.6.

Can you send me your file so I can take a look?

Sure…

IAP Test

Thanks a lot.

Here is the snippet of my code that works using version 1.1.3 for comparison. When I replace the import and change PluginWrapper to SDKBox it crashes. (The SDKBox files are also updated per the doc.)

       
package org.cocos2dx.cpp;
import android.content.Intent;
import org.cocos2dx.plugin.PluginWrapper;

public class AppActivity extends BaseGameActivity {
	public static Context mContext;
	private static Activity me = null;

    protected void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	if(savedInstanceState==null) {
    		me = this;
    		mContext = AppActivity.this;

        	PluginWrapper.init(this);  //Crashes on this Lin for 1.1.5

	}

    protected void onStart() {
        super.onStart();
        PluginWrapper.onStart();
    }

    public void onStop() { 	
        super.onStop();
        PluginWrapper.onStop();
    }

    @Override
    protected void onPause() {
    	super.onPause();
    	PluginWrapper.onPause();
    }

    @Override
    protected void onResume() {
    	super.onResume();
    	PluginWrapper.onResume();
    }

    @Override
    public void onBackPressed() {
    	if(!PluginWrapper.onBackPressed()) {
    		super.onBackPressed();
    	}
    }
}

I made a new project on Cocos2dx 3.6 and was trying to implement SDKBox IAP 1.1.5. I am getting similar error as Joh. I used the SDKBox installer and modified the Cocos2dxActivity according to the doc.

This looks like a bug, we’ll try to fix that ASAP.

We’re still testing our new sdkbox release.
Here is a nightly build which I believe can fix your issue

https://goo.gl/Ff3GZZ
Once you setup the new sdkbox installer, you can install iap with the following command.

sdkbox import -b iap --staging 

Let me know if this solved your problem.

So, if you modify AppActivity.java, this won’t work as there is a bug with doing this. I think for now we must modify Cocos2dxActivity.java

Now works well :smiley: , thanks a lot @nite.

@slackmoehrle, you are right Cocos2dxActivity.java must be modified instead of AppActivity.java

My mistake, isn’t solved yet.

I forgot to save the Cocos2dxActivity.java :confused:

It’s still crashing in this line:

SDKBox.init(this);

Did no work for me, I am still getting error when I run the app on a device

No implementation found for void com.sdkbox.plugin.SDKBox.nativeSetAssetManager(android.content.Context, android.content.res.AssetManager) (tried Java_com_sdkbox_plugin_SDKBox_nativeSetAssetManager and Java_com_sdkbox_plugin_SDKBox_nativeSetAssetManager__Landroid_content_Context_2Landroid_content_res_AssetManager_2)

E/AndroidRuntime(32755): java.lang.UnsatisfiedLinkError: No implementation found for void com.sdkbox.plugin.SDKBox.nativeSetAssetManager(android.content.Context, android.content.res.AssetManager) (tried Java_com_sdkbox_plugin_SDKBox_nativeSetAssetManager and Java_com_sdkbox_plugin_SDKBox_nativeSetAssetManager__Landroid_content_Context_2Landroid_content_res_AssetManager_2)
E/AndroidRuntime(32755): at com.sdkbox.plugin.SDKBox.nativeSetAssetManager(Native Method)
E/AndroidRuntime(32755): at com.sdkbox.plugin.SDKBox.init(SDKBox.java:61)
E/AndroidRuntime(32755): at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:227)
E/AndroidRuntime(32755): at android.app.Activity.performCreate(Activity.java:5933)
E/AndroidRuntime(32755): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
E/AndroidRuntime(32755): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2282)
E/AndroidRuntime(32755): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
E/AndroidRuntime(32755): at android.app.ActivityThread.access$900(ActivityThread.java:147)
E/AndroidRuntime(32755): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
E/AndroidRuntime(32755): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(32755): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(32755): at android.app.ActivityThread.main(ActivityThread.java:5254)
E/AndroidRuntime(32755): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(32755): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(32755): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
E/AndroidRuntime(32755): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)

can you show me your Cocos2dxActivity.java

Please download the file, its in the zip

Cocos2dxActivity.java.zip (4.2 KB)

I was able to reproduce that crash, it’s really strange, I think on certain version of cocos console does strip away static lib.

Can you try this, and let me know if it works for you guys

In your Android.mk
Change

LOCAL_STATIC_LIBRARIES := cocos2dx_static PluginIAP sdkbox

To

LOCAL_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES +=  PluginIAP sdkbox

It is not crashing anymore, i changed from

LOCAL_STATIC_LIBRARIES := cocos2dx_static PluginIAP sdkbox android_native_app_glue

to

LOCAL_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += PluginIAP sdkbox android_native_app_glue

Thank you

Thanks “nite”, I tried your hack with LOCAL_WHOLE_STATIC_LIBRARIES, but it did not work for me. I got the same crash at the same line on the init command. Are the sdkbox.jar and compiled binaries available for the nightly download version outside of using the installer?

So you’re using cocos2d-x 3.6 can you tell me what version of android-ndk are you using?