2

Now I managed to sign the apk (using Eclipse Android Tools) and adb install .. to the device for testing.

But this removed the debug function, e.g. "step over" which make problem tracing much more difficult.

Is it possible to debug the inapp billing using Eclipse?

Ryan
  • 10,041
  • 27
  • 91
  • 156
  • In-App billing is complex. You are better off by just getting a helloworld working quickly and then make changes as you go. So that u can make small changes and test. Trust me, it sounds easy, but there is a lot to do, to get it right. Dont miss out on even a single sentence of the android documentation for in-app billing. But first get hello world working, your feature done with, and then read thru the doc, to ensure that you do as per their guidance. – Siddharth Jun 25 '12 at 20:01

3 Answers3

3

Unfortunately I don't think there is any way to step debug, I have just been using print outputs. This is due to the fact that you have to sign your app with a release key in order for it to communicate properly with the billing service. Very annoying.

2

When you go through the in app billing documentation, you kinda realize that it can take substantial amount of time to understand this complex piece of technology. Most developers feel the need for a working HelloWorld, and then later play around with the builds.

I have uploaded 2 projects

  1. The android sample project. You can download this project, and immediately run the sample. This will help you quickly debug/trace thru and figure out how the in app billing works.

  2. A cleaned up project to help you integrate your app quickly. This can help like a library. Just integrate make your “purchase requests” on your “checkout” button action.

Mind you : I have not incorporated the security recommendations. Read android in app billing documentation. Until then you are on your own risk.

For 1

  • Download “http://www.4shared.com/file/f5wH3qke/InAppBilling1.html
  • Create a new gmail account for all correspondence (Why, I will explain below)
  • Pay that 25$ and purchase a “Market Place” account.
  • Import the project to your eclipse environment
  • Create a signed application apk, File-Export-Select Your Project-Create OR Use keystore, it should be valid for 25 years from today.
  • Upload the signed apk to the market place as a “Draft Application”, DO NOT PUBLISH it.
  • For the uploaded apk, you need to add “In App Products”. You will find this link on the home page for your uploaded apk.
  • In Security.java dont forget to add your “public key” from your market place account “edit profile” page.
  • On the “In App Product List”, you need to add the following products one by one
    • The text below should used as “In app Product id”
    • sword_001 as Managed
    • potions_001 as Unmanaged
    • Title and Description dont matter (for testing purpose). Add what you need here.
    • Cost add 1$ (minimum)
  • Click auto fill
  • Save

Publish the in app project (dont get confused here, you only need to publish the in app product, NOT the APP)

  • In the test account, add your personal gmail id here. Now, this gmail account needs to be configured as your first gmail account on your phone.
  • Yes, this WONT work on your emulator
  • Now the sample app should work.

For 2

Download “http://www.4shared.com/file/h8YnJyf_/InAppBillingIntegration.html

To integrate, in your calling activity initialize the checkout code

Handler handler = new Handler() ;
CheckoutPurchaseObserver checkout = new CheckoutPurchaseObserver(this, handler);

To send the checkout request for your product

checkout.sendCheckoutRequest(purchaseUri.toString(),null);

Important Note :

  • This purchaseUri is the “In-app Product ID” of your resource on the “market.android.com/publish-->Create New In-App Product” options. This string should be set as the “in app product” id.
  • That’s why the “id” is most important. The “In-App Product ID” is how you refer to that particular product.
  • Also, in Security.java dont forget to add your “public key” from your market place account “edit profile” page.**

Debugging Notes

  • LogCat will show all errors as InAppBilling tag
  • This project creates a shared_preferences named “inappbilling” And debug is set to true
  • The androidmanifest.xml may not be needed since this project does not have a home screen.

Why do we need to create a new gmail account ?

Simple. The account you purchase your market place account for, cant be used for “testing” your in app billing. Since you cannot purchase products for yourself. And your primary account on your device should be set as a “test account” on the market place account. Chicken-Egg issue here. Hope its clear.

An interesting blog I came by “http://crazyviraj.blogspot.com/2011/06/some-notes-on-implementing-in-app.html“ (not mine).

Siddharth
  • 9,349
  • 16
  • 86
  • 148
  • I want to download your codes but it require me to signup a new account. Can you put in somewhere like github to share it? – Ryan Jun 26 '12 at 16:38
-1

In my app, I used the test product id, android.test.purchased, which will simulate the actual buying process (ie, will show the in app dialog and you'll be able to purchase and get a response that can be handled by your application). Using that product id, you can run the in app code on the device (unsigned) via eclipse over usb connection. You still might need to work around some things for testing (ie, account for the fact that you are using a testing product id and not your real id), but I found using that product ID did help me quite a bit.

See the testing section of the in app billing guide

stuckless
  • 6,515
  • 2
  • 19
  • 27