Update to Billing Library 4(sdkbox)

Hi @chuoihottieu, are you sure you haven’t changed anything else in your update? From your logs it is hard to say what is going on.

@bluewind00 Thanks for sharing, it is a very good “base” for the future improvements. Please make it public again :slight_smile:


I make it public the repository again.
Again, this is a sample and is not guaranteed to work.


hi @kds @bluewind00
i replace sdkbox::IAP with mingos::IAP follow the instructions, it’s work perfert on device support native arm64-v8a, but crash on armeabi-v7a without reason.
for example Samsung Galaxy A13 5G: ABI support: armeabi-v7a, armeabi.
Anyways thanks you guys atleast i upgraded to billing v4 before 1.11.2022!

Just replace
in ‘proj.android\gradle.properties’

bluewind00, thank you very much a lot (you are our hero); I’ve updated your code a bit, to get quantity of purchased products; it works even on Android 4.4.2. (debug and release)

…Now I will try to insert it into my project (seems not so easy).

These are files that can be copied directly into your project.





Next is a set of files that may conflict with your project’s code.
Please incorporate the necessary parts of your project.


After two days of crashes and black screens, at last seems I used you code. It was hard (for me), because:

  1. I used separate object (in my c++ code):

sdkbox::IAP::setListener(m_IAP_obj); // m_IAP_obj class extends : sdkbox::IAPListener

And you use the main class for the listener (object) :

class SampleScene : public cocos2d::Scene, public mingos::IAPEventListener { // your code
class HelloWorld : public cocos2d::Layer // my past code

  1. Also there are tiny difference in:

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

mPurchaseManager = new PurchaseManager(this); // is it possible to change this file to use as listener not AppActivity class (object), but something else?

Thank you for your great job! :slight_smile: Thanks to you, maybe our Cocos games will be alive for some more time.

1 Like

This is a very important point, but in order to create your own purchase process, you must leave the sdkbox.
This means applying the following code to AppActivity.

public class AppActivity extends Cocos2dxActivity { 

If you apply my code as it is below, you will not receive the notification after the purchase request with my code.
This is because SDKBoxActivity will receive the result of the process from the store.

public class AppActivity extends com.sdkbox.plugin.SDKBoxActivity 

In other words, leaving the code above is not an option for us.

mPurchaseManager = new PurchaseManager(this); // is it possible to change this file to use as listener not AppActivity class (object), but something else?

Are you saying you want to minimize changes to AppActivity?
Then you can do that by making PurcahaseManager a singleton.
If the intent of this question is to keep the following code as explained earlier, it makes no sense.

public class AppActivity extends com.sdkbox.plugin.SDKBoxActivity 

I have changed PurcahseManager to singleton in my latest code.

1 Like

Strange, but it works…

Thank you! :slight_smile:

Hi @bluewind00 ,

Thank you for your great job. You have saved my project :smiley:

For those who get mingos::IAP to work by installing the game from Android Studio, but it crashes if you install it from APK… DON’T FORGET TO ADD THESE LINES TO YOUR proguard-rules.pro:

-keep class iap.** { ; }
-dontwarn iap.


1 Like

just update recently one of my games to billing library 4, with this sample and it’s working great.
the only odd thing, is that sometimes I get these crashes:

Crashed: Thread: SIGSEGV  0x0000000000000000
#00 pc 0x175f30  (std::__ndk1::__function::__func<Java_iap_PurchaseEventListener_onInitialized::$_1, std::__ndk1::allocator<Java_iap_PurchaseEventListener_onInitialized::$_1>, void ()>::operator()() [Java_iap_PurchaseEventListener.cpp:76])
#01 pc 0x40ec34 (cocos2d::Scheduler::update(float) [functional:1867])
#02 pc 0x3f7d0c (cocos2d::Director::drawScene() [CCDirector.cpp:264])
#03 pc 0x3fa14c (cocos2d::Director::mainLoop() [CCDirector.cpp:1392])

line 76 is:


not sure if we should add a try catch there for the case of the listener not being present anymore…
or maybe its something else. any ideas?

I’m very grateful for your generosity in releasing this code. Does anyone have any thoughts on the best way to make use of it within a lua-based app?

I’m thinking either hack the lua wrappers that are supplied with sdkbox, or create a replacement sdkbox:IAP class that calls into this new code where possible and stubs anything that isn’t supported. I’m unsure what’s best though, so interested in what others with more experience with Android think.

Hmmm, I’m obviously not as smart as I hoped I was! :slight_smile: I’m struggling to understand how to make use of this in an existing cocos2d-x project, of either type - cpp or lua. I imagined if I stared at the instructions for long enough that it would become clear, but it’s not happening. This looks to be a standalone sample. So, is there an easy way to determine exactly which files need to be copied into an existing project and which files within the existing project need tweaking?

Sorry, ignore me: I can now see that more detailed instructions appear in this thread.