Question

I can't retrieve offering in Android

  • 26 November 2023
  • 1 reply
  • 210 views

Badge +2

I’ve already followed every steps in the documentation and I’m able to retrieve the offering lists in iOS device but not in Android device. The offering is always empty in Android Emulator for some reason.

Here is a few information that I already checked my self.

1. My App is already published and currently it’s available for Closed Testing in Play Console.
2. I already got all checkmarks in the Valid credentials(screenshot below)

 

3. Here is how I implement it in my code
 

class PurchaseApi {

static Future init() async {

late String _apiKey;

 

if (Platform.isAndroid) {

_apiKey = "Google API from ReveneuCat";

} else if (Platform.isIOS) {

_apiKey = "IOS API from ReveneuCat";

} else if (Platform.isMacOS) {

_apiKey = "IOS API from ReveneuCat";

} else {

_apiKey = "Google API from ReveneuCat";

}

 

await Purchases.configure(PurchasesConfiguration(_apiKey));

}

 

static Future<List<Offering>> fetchOffers() async {

try {

final offerings = await Purchases.getOfferings();

final current = offerings.current;

 

return current == null ? [] : [current];

} on PlatformException catch (e) {

print("Error fetching offerings: $e");

return [];

}

}

}

}

/// This is how I display it

 

final offerings = await PurchaseApi.fetchOffers();
 

if (offerings.isEmpty) {

ScaffoldMessenger.of(context).showSnackBar(SnackBar(

content: Text('No Offer Found'),

));

} else {
// Display PayWall
}

 

I’m always getting “No Offer Found” when I try to retrieve in Android Emulator. I’m not sure if I need to test it in Physical Device to be able to retrieve the offering.

Any help or suggestion on how to fix this issue would be really appreciated.


1 reply

Userlevel 3
Badge +5

If your products, offerings, or packages are empty it's most likely related to a configuration or setup issue in Apple/Google. We've put together a handy guide here that outlines the common reasons for this here: https://community.revenuecat.com/sdks-51/why-are-offerings-or-products-empty-124. In terms of using Android Emulator, you should be able to use, but but should make sure that Google Play services are installed on the emulator. Are you testing using a sandbox account? If not, you can follow this guide on testing with a sandbox account

Reply