Billing service is not available on the device. (answer: 3: billing is not available)

I have been struggling with this problem for several days. I know that there are many questions with the same problem in SO, but I could not get it to work.

What I've done

  • Beta APK Uploaded
  • Created Trading Account
  • Test user added

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

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

What i tried

The only thing I did not do from this list was to install the license verification library (LVL). But I could not find any information that this step is necessary for an in-app purchase. If it’s not necessary, I want to do it without this library, because I really don’t need it, as indicated on the Google website.

The Google Play licensing service is primarily for paid apps that want to make sure that the current user has actually paid for the app on Google Play.

Is there something I missed?

+5
source share
2 answers

Finally, I got him to work! The problem was this: even though I put IInAppBillingService.aidl in the package com.android.vending.billing , 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 problem, I removed and updated the com.android.vending.billing package using IInAppBillingService.aidl . Therefore, if you have the same problem, double check where IInAppBillingService.java was created.

+1
source

I recently ran into this problem. As Bona Fide wrote, the package declaration in the IInAppBillingService.aidl file must be set to "com.android.vending.billing", and the helpl file must be found inside the corresponding directory using Explorer. Also (and this was the problem in my case), in IabHelper.java, the string parameter for serviceIntent should be the same as the package name containing the IInAppBillingService.aidl file.

 Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");// correct package name: com.android.vending.billing serviceIntent.setPackage("com.android.vending"); List<ResolveInfo> intentServices = mContext.getPackageManager().queryIntentServices(serviceIntent, 0); if (intentServices != null && !intentServices.isEmpty()) { // service available to handle that Intent mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); } else { // no service available to handle that Intent if (listener != null) { listener.onIabSetupFinished( new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE, "Billing service unavailable on device.")); } } } 
0
source

Source: https://habr.com/ru/post/1246218/


All Articles