Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin In App Billing Plugin could not connect

I have used this plugin: https://github.com/jamesmontemagno/InAppBillingPlugin to implement the in app billing since the component was removed. I have installed the nuget: Plugin.InAppBilling

In the Android, I have create a class called InAppBillingService where I implement here to get the products and purchase an item. Here are the codes:

var billing = CrossInAppBilling.Current;
var connected = await billing.ConnectAsync();

And it returns false everytime. I could not connect.

I have added in my AndroidManifest this:

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

And in the MainActivity:

protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            InAppBillingImplementation.HandleActivityResult(requestCode, resultCode, data);
        }

And in onCreate: CrossCurrentActivity.Current.Init(this, bundle);

Please advice what else I should do so that I could connect. And what are other reasons why it always return false when tried to connect. I'm testing in emulator. Thank you.

like image 711
Jen143 Avatar asked Dec 21 '25 00:12

Jen143


1 Answers

I'm testing in emulator.

That's the reason of the problem. As written here, Billing does not work on Android emulators. Use a real device.

like image 67
K232 Avatar answered Dec 22 '25 13:12

K232



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!