Question

I am trying to test in-app billing in my Android application. The problem is, it appears my market is not up to date since I can't bind to the billing service(I am using the Android example code from here. I keep getting the message This app cannot connect to Market. Your version of Market may be out of date. You can continue to use this app but you won\'t be able to make purchases.

I tried updating the market by opening it, hitting the home, and waiting 5-10 minutes and trying again as outlined here, but it didn't fix the problem. I am testing on a Nexus One with no phone connection - just over WiFi(not sure if this is relevant) with OS 2.2. Has anyone else run into this problem?

Here is the code from my activity:

if (!mBillingService.checkBillingSupported()) {
    showDialog(DIALOG_CANNOT_CONNECT_ID);
}

and this is the code from my billing service that is showing the billing is not supported:

public boolean checkBillingSupported() {
    return new CheckBillingSupported().runRequest();
}

    class CheckBillingSupported extends BillingRequest {
    public CheckBillingSupported() {
        // This object is never created as a side effect of starting this
        // service so we pass -1 as the startId to indicate that we should
        // not stop this service after executing this request.
        super(-1);
    }

    @Override
    protected long run() throws RemoteException {
        Bundle request = makeRequestBundle("CHECK_BILLING_SUPPORTED");
        Bundle response = mService.sendBillingRequest(request);
        int responseCode = response.getInt(Consts.BILLING_RESPONSE_RESPONSE_CODE);
        if (Consts.DEBUG) {
            Log.i(TAG, "CheckBillingSupported response code: " +
                    ResponseCode.valueOf(responseCode));
        }
        boolean billingSupported = (responseCode == ResponseCode.RESULT_OK.ordinal());
        ResponseHandler.checkBillingSupportedResponse(billingSupported);
        return Consts.BILLING_RESPONSE_INVALID_REQUEST_ID;
    }
}


    private boolean bindToMarketBillingService() {
    try {
        if (Consts.DEBUG) {
            Log.i(TAG, "binding to Market billing service");
        }
        boolean bindResult = bindService(
                new Intent(Consts.MARKET_BILLING_SERVICE_ACTION),
                this,  // ServiceConnection.
                Context.BIND_AUTO_CREATE);

        if (bindResult) {
            return true;
        } else {
            Log.e(TAG, "Could not bind to service.");
        }
    } catch (SecurityException e) {
        Log.e(TAG, "Security exception: " + e);
    }
    return false;
}
Was it helpful?

Solution

Maybe it requires the phone to have a mobile data connection. You can try to install the latest market app manually.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top