How to clear the "in-app billing service" cache
Asked Answered
J

6

20

In the documentation for in app billing (v3), it says: "Upon a successful purchase, the user’s purchase data is cached locally by Google Play’s In-app Billing service."

I now want to thoroughly test my app's billing code and wish to clear that cache. Its important because without the data being in the cache, it may take a little longer to collect the data - or it may not be accessible at all. I want to test that my app can handle these cases.

So is there a way to clear that cache?

Jacki answered 25/3, 2013 at 15:15 Comment(0)
H
10

This should work, although then you may need to authenticate on Play Store again:

enter image description here

Hairworm answered 28/3, 2013 at 8:20 Comment(5)
Re: "This should work" - but are you sure? Do you have a reference?Jacki
Well, just go and test it. It might work although it will incur in other data loss related to Google Play, and the data will come back once your profile is read again.Rea
@Jacki I suggest you disconnect your device from the net check if you get a response from the cache, then clear the cache and check again. if you don't get a reply then you managed to clear it. I would also clear the cache of the app called "Google Play Services".Watertight
Try to clear cache, disconnect from network, and if data are not available, then cache is cleared.Hairworm
@Jacki I can confirm that on my Nexus 4 the method mice suggested works.Watertight
H
27

You can do this with adb (works for non-rooted as well):

adb shell pm clear com.android.vending

It's as simple as that!

Hippocrates answered 20/1, 2017 at 12:18 Comment(2)
@Artsait English please; Anyhow, it's a cli command for the adb cli. Fire up your terminal and run it, it'll clear the Google Play app cache.Characteristic
Perfect. Also, this might be project-specific, but sometimes I had to clear my app's cache and the Google Play's cache several times before I got rid of the cached SKU price. But it always worked eventually.Gobo
H
10

This should work, although then you may need to authenticate on Play Store again:

enter image description here

Hairworm answered 28/3, 2013 at 8:20 Comment(5)
Re: "This should work" - but are you sure? Do you have a reference?Jacki
Well, just go and test it. It might work although it will incur in other data loss related to Google Play, and the data will come back once your profile is read again.Rea
@Jacki I suggest you disconnect your device from the net check if you get a response from the cache, then clear the cache and check again. if you don't get a reply then you managed to clear it. I would also clear the cache of the app called "Google Play Services".Watertight
Try to clear cache, disconnect from network, and if data are not available, then cache is cleared.Hairworm
@Jacki I can confirm that on my Nexus 4 the method mice suggested works.Watertight
T
1

Restart your device. That works for me every time! If you have annulated the order in google wallet you must also wait for it to be cancelled there. It shoud say "Cancelled: Order will not be delivered".

Treasury answered 3/6, 2014 at 7:20 Comment(1)
Restarting the device does not clear the cache for me; verified this by ensuring there was no network connection from the device, so my SkuDetails have definitely been retrieved from a cache.Cutlass
B
0

So is there a way to clear that cache?

As far as I know, no. There is no way for a developer to clear Google Play's IAB cache.

You can find this useful: Testing In-app Billing, from the official Android documentation.

Brina answered 28/3, 2013 at 23:36 Comment(0)
B
0

If Par Nils answer not work - try to remove application and execute

adb shell am clear-debug-app
Buffoon answered 14/9, 2020 at 13:49 Comment(0)
I
-1

Couldn't you create a new emulated android install from the android development kit... then save that as a "snapshot" to before you logged in and it created all of the billing cache? Then you can just fire up a fresh instance of that VM and run your code without there already being a billing cache.

EDIT: If you cannot do so with the emulator, I'd suggest having a phone that is rooted and rom'ed. Take a full system snapshot with Rom Manager (Nandroid Backup) and then test out your app. When you wish to reset, restore your backup via Rom Manager and you are back to before you logged into the market (and activated the billing cache). It honestly takes longer for your phone to reboot than to actually restore the data... so it's pretty fast (I do it all the time since I'm an avid root/rom-er.

Ikkela answered 3/4, 2013 at 18:28 Comment(2)
On the page developer.android.com/google/play/billing/billing_testing.html it says: "You cannot use the emulator to test In-app Billing".Jacki
@Jacki you can test in-app billing on BlueStacks.Steinbach

© 2022 - 2024 — McMap. All rights reserved.