0

(on Android) In my code when I want to start fetching products IDs the code never goes past this line:

final bool isAvailable = await InAppPurchase.instance.isAvailable();

And sometimes randomly it executes that line and stops here:

    try {
      ProductDetailsResponse productDetailResponse = await InAppPurchase.instance.queryProductDetails(_productIds.toSet());
      //...
    } on PlatformException catch (platformException) {
      print(platformException);
    } catch (error) {
      print(error);
    }

I've put both lines in a try-catch error but no error nor exception. I am clueless at this point.

I'm using in_app_purchase: ^2.0.0 and Flutter 2.5.3 stable channel

I'd appreciate if you have any hint.

P.S. everything works fine on iOS

Maysam
  • 7,246
  • 13
  • 68
  • 106
  • check ==> https://stackoverflow.com/questions/56581534/flutter-not-finding-any-products-for-in-app-purchases – Awais Rehman Dec 09 '21 at 15:03
  • @AwiasRehman it's not that, it does not execute the line, that's the problem. – Maysam Dec 09 '21 at 15:05
  • I recently had a dev with a similar problem and it was caused by including the android payments library in their build.gradle file. – Developer Extraordinare Dec 09 '21 at 15:13
  • @developerextraordinare what do you mean? i'm putting what the documentation says `implementation "com.android.billingclient:billing-ktx:$billing_version"` – Maysam Dec 09 '21 at 15:19
  • `Note: It is not necessary to depend on com.android.billingclient:billing in your own app's android/app/build.gradle file. If you choose to do so know that conflicts might occur.` Taken from https://pub.dev/packages/in_app_purchase – Developer Extraordinare Dec 09 '21 at 15:21
  • Removing it did't help. – Maysam Dec 09 '21 at 15:26

2 Answers2

1

Now I have the answer: Removing flutter_inapp_purchase package fixed it! I guess there should have been a warning at least!

Maysam
  • 7,246
  • 13
  • 68
  • 106
0

I had exactly the same problem. Removing the billing client implementation from the app-level build.gradle solved it. See this answer for details.

Ronald Blüthl
  • 311
  • 4
  • 9