question

ojhatushar avatar image
ojhatushar asked ·

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

Hi
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);
ID.add(ord.getDiscounts().get(i).getId());
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:-

orderConnector.addDiscount(orderID,discount);

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(ServiceConnector.java:199
at com.clover.sdk.v1.ServiceConnector.execute(ServiceConnector.java:245)
at com.clover.sdk.v3.order.OrderV31Connector.getOrder(OrderV31Connector.java:204)
at ai.predictivemarketing.volumediscount.service.CalculationService$AddDiscountAsyncTask_2$2.execute(CalculationService.java:1267)
at io.realm.Realm.executeTransaction(Realm.java:1493) 
at ai.predictivemarketing.volumediscount.service.CalculationService$AddDiscountAsyncTask_2.doInBackground(CalculationService.java:1038) 
at ai.predictivemarketing.volumediscount.service.CalculationService$AddDiscountAsyncTask_2.doInBackground(CalculationService.java:916) 
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)
Orders
9 comments
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 (https://cloverdevkit.com/) 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

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?
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.

Welcome to the
Clover Developer Community