Skip to content
Advertisement

Billing service unavailable on device. (response: 3:Billing Unavailable)

I’ve been struggling with this problem for days now. I know there are a lot of questions with the same problem on SO but i couldn’t get it to work.

What I have done

  • Uploaded APK in beta phase
  • Created Merchant account
  • Added test user

Code

AndroidManifest.xml

<uses-permission android:name="com.android.vending.BILLING" />

MainActivity.java

public class MainActivity extends AppCompatActivity {
    private IabHelper mHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        // ...
        
        setupInAppBillings();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }
    
    // [....]

    private void setupInAppBillings() {
        String base64EncodedPublicKey = "MY PUBLIC KEY";

        mHelper = new IabHelper(this, base64EncodedPublicKey);
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                if (!result.isSuccess()) {
                    Toast.makeText(getContext(), "In-app Billing setup failed: " + result, Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(getContext(), "In-app Billing is set up OK", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}

Tested on

  • Huawei P8 (Google Play Version 6.2.14)
  • In Switzerland, so a supported country for In-App Billing

What I’ve tried

The only thing I haven’t done from this list is the setup of the License Verification Library (LVL). But I couldn’t find any information that this step is required for an In-App Purchase. If not needed I want to do it without this library because I don’t really need it as stated on the Google Site.

The Google Play Licensing service is primarily intended for paid applications that wish to verify that the current user did in fact pay for the application on Google Play.

Is there something I miss?

Advertisement

Answer

Finally I got it to work! The problem was the following: Even though I put the IInAppBillingService.aidl in the com.android.vending.billing package, the generated class was in the wrong package as you can see in the code below.

/*
* This file is auto-generated.  DO NOT MODIFY.
* Original file:     C:\path\src\main\aidl\com\android\vending\billing\IInAppBillingService.aidl
*/
package billing;

public interface IInAppBillingService extends android.os.IInterface { //... }

To solve this, I deleted and recreated the com.android.vending.billing package with the IInAppBillingService.aidl. So if you have the same problem, check twice where the IInAppBillingService.java was generated.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement