Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid In-App Billing v3: "Can't perform operation: queryInventory"
    primarykey
    data
    text
    <p>I have setup In-App Billing for the first time using the new v3 API. It is working correctly on my devices but I have received a lot of error reports from other users.</p> <p>One of them is: </p> <pre><code>java.lang.IllegalStateException: IAB helper is not set up. Can't perform operation: queryInventory at my.package.util.iab.IabHelper.checkSetupDone(IabHelper.java:673) at my.package.util.iab.IabHelper.queryInventory(IabHelper.java:462) at my.package.util.iab.IabHelper$2.run(IabHelper.java:521) at java.lang.Thread.run(Thread.java:1019) </code></pre> <p>And another one is:</p> <pre><code>java.lang.NullPointerException at my.package.activities.MainActivity$4.onIabSetupFinished(MainActivity.java:159) at my.package.util.iab.IabHelper$1.onServiceConnected(IabHelper.java:242) </code></pre> <p>My activity implementation follows Google's example code (all referenced classes are untouched from the example):</p> <pre><code>IabHelper mHelper; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //... mHelper = new IabHelper(this, IAB_PUBLIC_KEY); mHelper.enableDebugLogging(true); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (!result.isSuccess()) { // Oh noes, there was a problem. return; } // Hooray, IAB is fully set up. Now, let's get an inventory of // stuff we own. mHelper.queryInventoryAsync(mGotInventoryListener); //***(1)*** } }); } // Listener that's called when we finish querying the items we own IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() { public void onQueryInventoryFinished(IabResult result, Inventory inventory) { if (!result.isFailure()) { if (inventory.hasPurchase(SoundsGlobals.IAB_SKU_PREMIUM)){ //we are premium, do things } } else{ //oops } } }; @Override protected void onDestroy() { if (mHelper != null) { mHelper.dispose(); mHelper = null; } super.onDestroy(); } </code></pre> <p>I assume that both errors originate from the line marked as <code>***(1)***</code></p> <p>What is the cause of these errors? If I'm calling <code>queryInventoryAsync</code> only within <code>onIabSetupFinished</code>, how is it possible that <code>mHelper</code> is null, or that <code>mHelper</code> is not set up?</p> <p>Does anyone know a solution to this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload