In-App Billing test: android.test.purchased already owned

后端 未结 16 1340
情深已故
情深已故 2020-12-07 08:09

I am currently testing In-App Billing for a future app, and after I successfully \"bought\" the test item \"android.test.purchased\" the first time, I now receive the respon

相关标签:
16条回答
  • 2020-12-07 08:52

    In my case, I just needed to clear the apps cache. After clearing the cache, I was able to initiate the purchase flow again.

    From my device (4.4.2), I navigated to "Settings->Application manager". Next, I selected the app from the "DOWNLOADED" tab, and then "Clear cache".

    0 讨论(0)
  • 2020-12-07 08:54

    No need to write any special consumption code. Just use the adb command for clearing the Google Play Store data:

    adb shell pm clear com.android.vending
    
    0 讨论(0)
  • 2020-12-07 08:55

    Add this code to a thread to initiate consume request.

    int response = mService.consumePurchase(3, getPackageName(), purchaseToken);
    

    Here for the purchase test, purchaseToken is

    purchaseToken = "inapp:" + getPackageName() + ":android.test.purchased";
    

    And

    if (response == 0)
    

    then the consumption is successful.

    also don't forget to make mService public in

    IabHelper.Java

    then it would be possible to access like this:

    int response = mHelper.mService.consumePurchase(3, getPackageName(), purchaseToken);
    
    0 讨论(0)
  • 2020-12-07 08:57

    In my opinion if your program is not designed to consume the item you do not need to tweak the code in order to clear the memory of an outside vendor. This will make your code more fragile and you will have then to spend a lot of time to add and remove code that does not belong to your software so it is a bad design to implement a solution like that.

    The best solution that worked for me to clear android.test.purchased was

    adb uninstall com.yourapp.name
    

    and then

    adb shell pm clear com.android.vending
    

    I did not need to clear cash and to browse my apps setting or to change code for that. I did need to add the adb to path variables of windows system which was pretty straight forward. So yes you need to use adb which you probably need anyway so..

    You just add your C:\ ...\android-sdk\platform-tools; in windows path in environment variables, and I imagine that it is pretty simple in mac and linux os as well. Hope it helps someone to spend few days less with implementing android in app billings.

    0 讨论(0)
提交回复
热议问题