Solved

Flutter - canMakePayments() never returns on Android

  • 19 August 2021
  • 4 replies
  • 125 views

Badge +4

To replicate:

Using latest Flutter plugin 3.4.1 and the ‘purchase_tester’ example project

Add an ElevatedButton that calls canMakePayments() 
eg replace the ‘UpsellScreen’ build method with this

@overrideWidget build(BuildContext context) {  return ElevatedButton(    onPressed: () async {      bool _storeAvailable = false;      try {        print("Checking availability");        _storeAvailable = await Purchases.canMakePayments();        print("Store available? $_storeAvailable"); //This line never prints      } on PlatformException catch (e) {        var errorCode = PurchasesErrorHelper.getErrorCode(e);        print("Error was $errorCode");      }    },    child: Text("Check Store Available"),  );}

On Android the call never returns (on iOS it works as expected)

Expected result:
bool returned within a reasonable time (or an exception)

Testing info:
This function was working correctly on vs 3.3.0 of the plugin.

Tested on Android Pixel 4a
Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64)
 

icon

Best answer by cody 4 October 2021, 17:01

View original

4 replies

Userlevel 6
Badge +8

Hey @Mark Chaplin!

Version 3.4.5 of the Flutter SDK resolves this issue- give it a shot and let me know if you’re still having issues!

Badge +4

Thanks, I’ll try it. Seems to be mentioned in the 3.4.5 change log too..
https://pub.dev/packages/purchases_flutter/changelog

Can the SDK team confirm?

Badge +1

@Mark Chaplin I had the same issue with version 3.4.0, after updating to 3.4.5 canMakePayments work and returning result also for android

Userlevel 6
Badge +8

Hey @Mark Chaplin! 👋

Thanks for reaching out and letting us know about this - the SDK team is looking into this and I’ll follow up as soon as I have more information.

Reply