ojhatushar avatar image
ojhatushar asked ·

Binding exception :- com.clover.sdk.v1.BindingException: Could not bind to Android service exception

We have make an app using clover sdk in which we are applying discount . We have a background service in that app, that is updating the order and we are removing discount and putting order level discount again when some criteria gets fulfilled on register app, using below method of clover sdk:-

Order ord = orderConnector.getOrder(orderID);
orderConnector.deleteDiscounts(orderID, ID);

but sometime it show binding exception on first line. and take delay in showing discount on dashboard of register app I have already connected orderconnector and discount is applied on order level using below method:-


Is these exception came only in emulator and not in real device?
Because I am testing on emulator and all apps are updated of emulator and I have emulated and tested on both clover mini emulators first and second generation.but same below exception repeated.

Exception is as shown:-
I/ServiceConnector: waitForConnection result: true, retryCount: 0
I/ServiceConnector: waitForConnection result: true, retryCount: 1
I/ServiceConnector: waitForConnection result: true, retryCount: 2

com.clover.sdk.v1.BindingException: Could not bind to Android service
at com.clover.sdk.v1.ServiceConnector.waitForConnection(
at com.clover.sdk.v1.ServiceConnector.execute(
at com.clover.sdk.v3.order.OrderV31Connector.getOrder(
at ai.predictivemarketing.volumediscount.service.CalculationService$AddDiscountAsyncTask_2$2.execute(
at io.realm.Realm.executeTransaction( 
at ai.predictivemarketing.volumediscount.service.CalculationService$AddDiscountAsyncTask_2.doInBackground( 
at ai.predictivemarketing.volumediscount.service.CalculationService$AddDiscountAsyncTask_2.doInBackground( 
at android.os.AsyncTask$
at at android.os.AsyncTask$SerialExecutor$
at java.util.concurrent.ThreadPoolExecutor.runWorker( 
at java.util.concurrent.ThreadPoolExecutor$ at
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

This could be due to the difference between how the emulator and the device handle service connections.

I strongly suggest you purchase a Clover DevKit ( so that you can closely match the merchant experience.

1 Like 1 · ·

This is most often caused by an app exhausting all of the binder threads into the process that is hosting the service (in this case com.clover.engine). Make sure you are calling disconnect() on your service connector instance when you are done with it. Make sure you do not have any other 3p apps installed that you could be causing the problem.

When you are app is failing like this, does the Register app work?

The fact that you are using an emulator should not be a factor here.

0 Likes 0 · ·
ojhatushar avatar image ojhatushar Jeffrey Blattman ♦♦ ·

Yes, Register app works at that time and I have also called disconnect() method on service connector instance when we are done with it and 3p apps are also not installed,then also same exception is repeated when using emulator.Any more solution for that, so that these exception can be removed.

0 Likes 0 · ·

The best thing you can do is to try and put together an MCVE that exhibits the problem. If your case it might be a simple app that repeatedly performs whatever operation you are calling on the connector.

0 Likes 0 · ·

I have seen this issue when trying to call Async using new AsyncBlah().execute().get();

Are you doing this?

0 Likes 0 · ·

No I am not calling this way:- new AsyncBlah().execute().get();

I am calling this way only:- new AsyncBlah().execute();

0 Likes 0 · ·

did you figure this out? we had another instance of this today and it turned out we had something like; new AsyncBlah().execute(); followed by spinning up a new activity which was destroying the context which passed to the connector! Moving the new activity code into the postExecute of the Async resolved the issue.

0 Likes 0 · ·
Show more comments

I am having this issue when trying to connect to the TenderConnector inside a kotlin coroutine.

0 Likes 0 · ·

1 Answer

Bryanne Vega avatar image
Bryanne Vega answered ·
Just out of curiosity,

do: Log.d("Connected",orderConnector.isConnected());
(Place it before making the getOrder call)
Have you've confirmed the services is running before making the call?
1 comment Share
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I had this issue and tenderConnector.connect() would return success, but tenderConnector.isConnected() would return false

0 Likes 0 · ·

Welcome to the
Clover Developer Community