可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I'm trying to use In-App billing:
mIabHelper = new IabHelper(this, BILLING_KEY);
mIabHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
@Override
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
Log.d(TAG, "Problem setting up In-app Billing: " + result);
}
}
});
And getting the error:
Problem setting up In-app Billing: IabResult: Billing service unavailable on device. (response: 3:Billing Unavailable)
Why? Tried to clear cache of the Play Store, didn't work for me.
回答1:
Well we can't help you without having much information.So instead i'll try to do a checklist for you incase you missed something:
1)Are you testing on an emulator?Billing services should be tested on devices,BUT if you
really have to test on the emulator,make sure the emulator has google play installed and set up.This is very important!
2)Did you set the correct permission in the manifest? (com.android.vending.BILLING)
3)If you are still testing the app,did you get a test app licence from the playstore,imported the lvl in your sdk,set up your licence verification library? (you can follow along here: setting up
4)On your activity onActivityResult did you correctly handle the activity result?As seen on the example from google you should do it this way:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.i(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
// Pass on the activity result to the helper for handling
if (!inappBillingHelper.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
else {
Log.i(TAG, "onActivityResult handled by IABUtil.");
}
}
Also having more information could be useful,like if you are testing on the emulator or device,device name,android version etc..
回答2:
This error indicates that you're connecting to the in-app billing service on your device, but that the service doesn't support IAB version 3. It may be that your device's version of Google Play only supports version 2 of IAB. What version of Google Play is running on your device?
Is your version of Google Play otherwise functional (e.g., can you open the Google Play store)? Sometimes, if the date on your device is off, or there is some other problem, Google Play itself can go South.
Finally, what's in your logcat output? It would be easier to provide assistance if you provided more detail.
回答3:
I got that error when I installed the App BEFORE I registered everything and set Google Play store up. Once I set the Google Play Store account up, the error went away.
回答4:
Wipe helped me. Strange error.
回答5:
The documentation for version 2.0 of the billing was actually more helpful than 3.0 for this one even though I'm using version 3.0 of the billing.
Here's how 2.0 describes it Response Code 3:
Indicates that In-app Billing is not available because the API_VERSION
that you specified is not recognized by the Google Play application or
the user is ineligible for in-app billing (for example, the user
resides in a country that prohibits in-app purchases).
For me I had to setup a test Google account on my phone first before testing. I forgot that step. Once I did that fixed it for me...
Look for Server Response Codes here:
http://developer.android.com/google/play/billing/v2/billing_reference.html
http://developer.android.com/google/play/billing/billing_reference.html
回答6:
I found a problem to fix, try root with ur LuckyPatcher, open config Toggles -> Disable billing.
回答7:
I had exactly this error when I removed all Google accounts from phone (thus wipe fixes because after wipe you probably set up an account after phone rebooted).
After I added an account I did not see this error.
Related issue What are the possibilities to get this error code 3 in InApp purchase?.
回答8:
Had the same problem.
My device was rooted and ROM'ed with an older version of Google Market which did not self-update.
You can verify your the Market/Play version by looking at it in the AppManager.
I actually decided to use another device, but I guess otherwise I would have to find a way to upgrade the Market/Play version.
回答9:
I got this error from wiping the Google Play cache. You have to reopen the Google Play app and accept the terms before it is functional for IAB again.
回答10:
This is because the account which is currently logged in the device is not registered in Google Developer Console.
TO resolve this problem,
1. Go to your Google Developer Consol
2. In Account Detail Tab, enter the email address(which is in device) in "Gmail accounts with testing access" and press the save button on the top.
Thats it.
回答11:
In my case I've set a different value for serviceIntent.setPackage("com.android.vending"); from IabHelper. Make sure you leave it with this value
回答12:
I had that same error and then noticed my phone was in Airplane Mode! Once connectivity was restored, I was good to go.
回答13:
IabHelper.java
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
It is an error if it is not possible to specify correctly the action and packageName to IInAppBillingService.aidl
.
回答14:
Have come up with the solution.
Try the below 3 steps:
- Clear the cache of GooglePlay app and Google Play services app.
- Remove IInAppBillingService.aidl file.
- Copy the above file again from sdk folder and paste it to the aidl folder in my app.
This problem usually occurs when we copy the aidl file from one project to another project.