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