0

I'm trying to use the Android in-app purchase system. I have one managed product only, and the problem is I cannot test it in debug mode with eclipse. When I sign my application and install it to developer console and to my phone everything is OK.

But I when want to debug my application with eclipse, I always gett RESULT_DEVELOPER_ERROR for restoreTransactions(). I want to check if this managed product is purchased before when my application is reinstalled.

What is the correct way to test managed products?

I assume I'm getting the error RESULT_DEVELOPER_ERROR because I'm working in debug mode and it's not the signed apk. If that's true, how can I debug my application for managed products?

Kara
  • 6,115
  • 16
  • 50
  • 57
penguru
  • 4,342
  • 11
  • 46
  • 56
  • @RivieraKid - I did not say, I want to test it in emulator. You have changed my question in a wrong way! I want to test it on the phone. And it's not possible to test in-app purchase in emulator.. – penguru Apr 03 '12 at 08:29
  • In that case, I misunderstood your comment - I apologise, feel free to rollback the edit. Having said that, the Testing in-app billing page I refer you to in my answer explains exactly how to test billing on a physical device. – RivieraKid Apr 03 '12 at 08:32

4 Answers4

1

This is an old question, but somebody may still find it useful.

You can actually debug inapp purchases:

  • create a custom debug keystore from your release keystore as described here: http://blogprogramistyandroid.blogspot.com/2011/04/converting-release-keys-to-debug.html

  • build a release .apk (might as well use your real release script, with proguard and stuff) and upload it to "alpha testing" section of your Play Store account. Do publish the alpha version. You may also need to add the test gmail account as a tester there (just create an empty G+ group with that account as an owner) - but it may also work without it, I haven't tried.

  • now do your debugging, using the custom debug key you've created in step 1, and making sure the app version in your manifest matches the version you've uploaded as an alpha version in the previous step.

  • you may have to wait for some time for the alpha version to get registered in Google's depths, but that may only be for downloading the test version from the app store.

Voila, you can now do step-by-step or whatnot and actually purchase real products.

P.S. and don't forget to delete that custom debug keystore after you're done debugging IAPs.

SVD
  • 4,743
  • 2
  • 26
  • 38
0

There is no way to test it if you have signed your app with the debug key.

NB you only need to sign with debug key if you want to run the debugger. I suggest signing with the release key and using good logging instead of debugging.

And make sure that you upload the same version of the app that you deploy to your device to the Developer Console (it can be draft, it doesn't need to be published). See In-app billing, can't make RESULT_DEVELOPER_ERROR go away

Community
  • 1
  • 1
William
  • 20,150
  • 8
  • 49
  • 91
0

Well, you can debug signed applications.

In manifest, set android:debuggable="true" inside <application> tag. Launch application, go to DDMS perspective in eclipse, find your application process in Devices tab, select it and attach debugger (green bug at tab menu).

Sver
  • 3,349
  • 6
  • 32
  • 53
-1

Please refer to the In-app billing reference, specifically, the description of the error:

Indicates that an application is trying to make an in-app billing request but the application has not declared the com.android.vending.BILLING permission in its manifest. Can also indicate that an application is not properly signed, or that you sent a malformed request, such as a request with missing Bundle keys or a request that uses an unrecognized request type.

I think you'll find that the problem is that the emulator does not have the Google Play Store installed (provided by the com.android.vending class) and therefore cannot support in-app billing.

The Testing in-app billing page explicitly states that in-app billing cannot be used with the emulator:

To test in-app billing in an application you must install the application on an Android-powered device. You cannot use the Android emulator to test in-app billing.

RivieraKid
  • 5,923
  • 4
  • 38
  • 47
  • Yes, probably I'm getting the error I'm not running the signed application in debug mode. But how can I debug signed application? – penguru Apr 03 '12 at 08:35