question

RyanM avatar image
RyanM asked ·

Custom Tender Not Showing in Production

It works perfectly in the sandbox. But when sent for approval they are not getting the custom tender. Code to connect the Tender looks like:

private void initializeMyTender(final Context context) {
    new AsyncTask<Void, Void, Exception>() {

        private TenderConnector tenderConnector;

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            tenderConnector = new TenderConnector(context, CloverAccount.getAccount(context), null);
            tenderConnector.connect();
        }

        @Override
        protected Exception doInBackground(Void... params) {
            try {
                tenderConnector.checkAndCreateTender(getString(R.string.tender_name), getPackageName(), true, false, new ServiceConnector.Callback<Tender>() {
                    @Override
                    public void onServiceSuccess(Tender result, ResultStatus status) {
                        ((MyApplication) getApplication()).setTenderId(result.getId());
                    }

                    @Override
                    public void onServiceFailure(ResultStatus status) {

                    }

                    @Override
                    public void onServiceConnectionFailure() {

                    }
                }); // initialization
            } catch (Exception exception) {
                Log.e(TAG, exception.getMessage(), exception.getCause());

                return exception;
            }
            return null;
        }

        @Override
        protected void onPostExecute(Exception exception) {
            if (exception != null) {
                displayToastMessage(exception.getMessage());
            }
            tenderConnector.disconnect();
            tenderConnector = null;
        }

    }.execute();
}

When they are testing it in production, however; the tender does not show up in the register. They sent a Logcat stacktrace with :

10-02 16:13:37.418 22753-22753/? E/ActivityThread: Activity com.my.application.Activities.MainActivity has leaked ServiceConnection com.clover.sdk.v1.tender.TenderConnector@423e8c78 that was originally bound here
    android.app.ServiceConnectionLeaked: Activity com.my.Application.Activities.MainActivity has leaked ServiceConnection com.clover.sdk.v1.tender.TenderConnector@423e8c78 that was originally bound here
        at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:978)
        at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:872)
        at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1569)
        at android.app.ContextImpl.bindService(ContextImpl.java:1552)
        at android.content.ContextWrapper.bindService(ContextWrapper.java:517)
        at com.clover.sdk.v1.ServiceConnector.connect(ServiceConnector.java:135)
        at com.clover.sdk.v1.ServiceConnector.waitForConnection(ServiceConnector.java:163)
        at com.clover.sdk.v1.ServiceConnector$1.run(ServiceConnector.java:241)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:841)

All the line numbers in the stack trace are outside of my code, and I'm not sure what I'm doing wrong as it works without issue in the sandbox. Anyone else have a similar issue or know what I've missed?
Custom TendersProduction
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.

RyanM avatar image
RyanM answered ·
I found the issue to be caused by a lack of permissions in the production app. As for the callback, I'm using it to store the TenderId because it returns a tender. Is there a better or cleaner way of doing that without doing a getTenders and looping through?
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.

zgreathouse avatar image
zgreathouse answered ·
I have been unable to reproduce this issue. As far as the error logs, a leak is being caused by a service connector not being disconnected.

One thing I don't quite understand about your code is why you are passing that last argument into checkAndCreateTender. You seem to be utilizing the other checkAndCreateTender method here and in doing so are passing a callback within an async function. However, all the ServiceConnector callback methods are executed on the main thread. ( See docs here on ServiceConnector)

The following try block in place of your try block should work just fine for initializing your tender.

try {
    // initialization
    tenderConnector.checkAndCreateTender(getString(R.string.tender_name), getPackageName(), true, false);
} catch (Exception exception) {
    Log.e("Initialize Tender", exception.getMessage(), exception.getCause());
    return exception;
}

*Try adjusting your tender initialization and double checking your code to make sure all service connectors are being disconnected properly.

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