Question

I've searched around for hours trying to figure this out. Here's what I have done so far. (Note: I'm developing in Android Studio)

  1. Generated a signed APK and uploaded to my developer console
  2. Made an in-app product and activated it
  3. Added the Billing permission to my manifest
  4. Extensively combed Stack to try and find similar problems.

Basically in logcat I see that IABHelper starts setup, but never completes at any time. (the listener never gets a callback)

private static final String TAG = "Preference Activity";
private static final String SKU_PRO = "desk.clock.pro.license";
static final int RC_REQUEST = 10001;
IabHelper mHelper;
private boolean mIsPremium;
private ArrayList<Preference> proSettings;
IInAppBillingService mService;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
    bindService(new
            Intent("com.android.vending.billing.InAppBillingService.BIND"),
            mServiceConn, Context.BIND_AUTO_CREATE);
    proSettings = new ArrayList<Preference>();
    ActionBar b = getActionBar();
    b.setDisplayHomeAsUpEnabled(true);
    colorListener();
    textureListener();
    bgColorListener();
    onPresetListener();
    gradListener();


    String base64Key = "[my key from dev console]";
    bindService(new
            Intent("com.android.vending.billing.InAppBillingService.BIND"),
            mServiceConn, Context.BIND_AUTO_CREATE);
    mHelper = new IabHelper(this, base64Key);
    mHelper.enableDebugLogging(true);
    Log.d(TAG, "Starting setup");
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        public void onIabSetupFinished(IabResult result) {
            if (!result.isSuccess()) {
                // Oh noes, there was a problem.
                Log.d(TAG, "Problem setting up In-app Billing: " + result);
            }
            Log.d(TAG, "Setting up success");

            Log.d(TAG, "querying inventory");
            mHelper.queryInventoryAsync(mGotInventoryListener);
            Log.d(TAG, "queried");
        }
    });
 IabHelper.QueryInventoryFinishedListener mGotInventoryListener
        = new IabHelper.QueryInventoryFinishedListener() {
    public void onQueryInventoryFinished(IabResult result,
                                         Inventory inventory) {

        if (result.isFailure()) {
            // handle error here
            mIsPremium = false;
            disableProAndRevertSettings();
        }
        else {
            // does the user have the premium upgrade?
            mIsPremium = inventory.hasPurchase(SKU_PRO);
            if(mIsPremium) {
                enableProSettings();
            }else {
                disableProAndRevertSettings();
            }
        }
    }
};
ServiceConnection mServiceConn = new ServiceConnection() {
    @Override
    public void onServiceDisconnected(ComponentName name) {
        mService = null;
    }

    @Override
    public void onServiceConnected(ComponentName name,
                                   IBinder service) {
        mService = IInAppBillingService.Stub.asInterface(service);
    }
};
 //rest of my activity

I get this line in my logcat but never anything after this 10-06 15:46:44.485 20787-20787/com.ssa.digitaldeskclock D/IabHelper﹕ Starting in-app billing setup.

Was it helpful?

Solution

Problem was fixed by obtaining a new version of all of the util classes for the IAB v3 sample. I added all the new files to my util directory and it went flawlessly. Hopefully this can help someone else out there. See this link for the source https://code.google.com/p/marketbilling/source/browse/v3/src/com/example/android/trivialdrivesample/util/IabHelper.java?r=5f6b7abfd0534acd5bfc7c14436f4500c99e0358

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