SecurityException Binder invocation to an incorrect interface (Inapp Billing)


Self Advertisement
—–Start of Advertisement——-
BUILD CAR POOL SOLUTIONS ON ANY DEVICE TO RUN ANYWHERE (www.mcruiseon.com). Introducing mCruiseOn, the java library /json api’s that you can use to build a car pool solution. Be the next avego.com, carpooling.com, zimride.com. mCruiseOn is your one stop API on EC2.
——End of Advertisement——-

I got this annoying exception when I tried to run the “In app billing” sample app. I followed all the required steps but kept getting this exception at load time.

I did the following
1) Setup a Market account
2) Renamed the package to not have “android” or “example”
3) Added the public key from the market profile to Security.java
4) Built/Signed the app
5) Added “inapp products” to the market place
6) Uploaded as draft app
7) Uninstalled the sample on the device
8) Installed it on the device
9) Ensured that market place was > 2.3.5
10) Setup a test account. And this test account should not be the account registered for this developer. Else it can be a security issue (buying your own product).
When I load, I get this annoying exception. Absolutely no help on any website.

Finally after a few hours of pulling out some more of my hair, I finally think of a root cause. The main reason that its a security issue can be only because of the public key or the test account. Thats it, it was the test account.

Root Cause 1
My registered account (A) with market place was my primary account with all the app’s, contacts and my life in short. The test account was my other gmail account (B), which did not have any apps. So, catch 22.

If I setup (A) as my primary account on android phone (samsung, which does not take its updates from google android, buts its own builds), then I land up in a Security Exception since A cannot be used as a test account. And the primary account on the device is considered as the test account when the sample in app billing app runs.

If I setup (B) as my primary account on the android phone, market application is 2.1, and not enough for the sample app to run. So you see, catch 22.

Solution was simple. I registered B as my market account (one more cost to my budget :)). But google being really nice, refunded my fee’s for A.

Mind you A was a new account, no apps published on this account and nothing pending for payment. It was a brand new account.

Root Cause 2
The public key can change when google activates/cancels accounts. So just reverify the public key and your Security.java file.

Root Cause 3 (THE worst of the root causes)
The AIDL file is referred from your BillingService.java file. Also remember that we modified the package name to “not” contain android ? The BillingService is “INCORRECTLY” referring to the older package (com.android…..).
Now, how do I know this ? Well, details are in the fine print. On the “http://developer.android.com/guide/market/billing/billing_integrate.html” page its mentioned that if you need debugging information set DEBUG = true in Consts.java. I did that and found a warning , before the SecurityException in LogCat.

Set Debug=true in Consts.java

Hope you understood it. If not, please comment on the blog, I’ll respond.

Advertisements

3 thoughts on “SecurityException Binder invocation to an incorrect interface (Inapp Billing)

  1. Hi, one more reason for the same exception with the same message (“binder invocation …”) could be if you copy the aidl file from the sample and change it’s java package. The IMarketBillingService.aidl file has to stay unmodified in an com.android.vending.billing package.

  2. Thx @ Anonymous:
    Had the same error and my problem was exactly what you described. I made package changes to the .aidl file before. I changed it back to it’s original state, did a build, tried the billing stuff again and the error was gone. Thx. Your advise saved me tons of time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s