Ad-Free Subscriptions on Android: Gate Banners with Entitlements
Banner inventory and user patience pull in opposite directions: the more slots you fill, the more likely your heaviest users start looking for an exit. One way out is to keep the ad-supported app as the default and sell a paid switch that turns banners off. This walkthrough covers that switch on Android — Google Play products, an entitlement that records who paid, and a Compose gate that decides whether an ad view is drawn. The SDK calls below follow the published engineering walkthrough; treat the dashboard and store steps as third-party guidance to verify against current documentation. The purchase dashboard and store connection referenced here are operated by {{OWNER_DASHBOARD_OPERATOR}}.
What you are building
The feature is a paid, optional tier that sits beside your existing ad revenue rather than replacing it. Before any banner is drawn, the app answers one question: does this user currently hold the ad-free entitlement? A yes skips the ad view; a no renders it. The purchase is an ordinary Google Play in-app purchase, and the entitlement is the flag your UI reads.
That gives you two audiences on one build. Users who never upgrade keep seeing ads, and users who want an uninterrupted session can pay to remove them. The work breaks into six parts: store connection, dashboard configuration, SDK initialization, entitlement checking, banner gating, and the purchase flow.
Connect Google Play and configure products
The first step is linking your Google Play account to the purchase dashboard, which lets you import products you already have. That connection also brings unified user identities, simpler subscription management, cross-platform analytics, and pricing visibility across stores. The official Google Play connection guide covers the credentials, and the Google Play product setup walkthrough adds step-by-step detail.
Before writing client code, get comfortable with four configuration objects, because each one plays a different role in the purchase path:
- A Product is a single in-app purchase that lives in the store (Apple App Store or Google Play).
- An Offering is the paywall grouping you configure in the dashboard; it is where pricing experiments and audience segmentation happen.
- A Package is the slot inside an offering that holds equivalent products across iOS, Android, and web under one identifier.
- An Entitlement is the access level a purchase unlocks. Your permission logic reads the entitlement, so store product identifiers stay out of feature checks.
The in-app purchases cheat sheet diagram shows how these nest together, and the quickstart plus product configuration article cover the dashboard clicks. The dashboard itself is operated by {{OWNER_DASHBOARD_OPERATOR}}.
Add and initialize the Purchases SDK
Add the Purchases SDK dependency to your build.gradle.kts file. The exact dependency line is delivered in the protected code module and should be used as supplied. Then initialize the SDK in your Application class. The initialization example configures the SDK with your API key, sets purchasesAreCompletedBy to subscription management platform so transactions are finished automatically, passes a null appUserID so an anonymous ID is generated, and enables diagnostics. The exact initialization code is in the protected module; do not retype or alter its field names. The dashboard and store connection used by these steps is operated by {{OWNER_DASHBOARD_OPERATOR}}.
Check the ad-free entitlement
The entitlement is the single source of truth for whether to show ads. Retrieve customer info with Purchases.sharedInstance.awaitCustomerInfo() inside a coroutine scope, then read the entitlement by its identifier and check isActive. The identifier must match the one configured in the dashboard. The exact check is in the protected code module.
A practical field map helps avoid mismatches:
- Dashboard entitlement identifier → the string used in the entitlement lookup.
- Dashboard product identifier → the value passed to awaitGetProducts.
- Offering and Package → the paywall grouping and cross-platform bundle, not the access flag.
- isActive → the boolean your banner composable consumes.
If the entitlement is missing or inactive, treat the user as not entitled and show the ad. If customer info cannot be retrieved, decide explicitly whether to fail open (show ads) or fail closed (hide ads); the source example does not prescribe this, so document your choice.
Gate AdMob and Audience Network banners
The gate lives at the composable boundary: hand the isEntitled boolean to the banner composable, and let the branch decide what renders. An entitled user gets an empty ad slot; everyone else gets the banner view. The AdMob version builds an AndroidView with AdSize.BANNER, an ad unit ID placeholder, and a loadAd call. The Audience Network version keeps the same if/else shape and swaps in that network's view. Both exact composables are delivered as protected code modules.
Keeping the check in one place means adding or retiring an ad network never touches purchase logic.
Run the purchase flow
Fetch product information with Purchases.sharedInstance.awaitGetProducts(productIds = listOf(...)), then start the purchase with Purchases.sharedInstance.awaitPurchase using PurchaseParams.Builder with the activity and the selected store product. The exact calls are in the protected code module.
One detail worth copying from the example: suppose your store holds period variants such as paywall_tester.subs:weekly, paywall_tester.subs:monthly, and paywall_tester.subs:yearly. Pass the base identifier paywall_tester.subs as the productIds value, and the call returns every related product as a list you can present for selection. The purchase call then opens the Google Play purchase dialog so the user can complete the transaction. The dashboard that serves product information is operated by {{OWNER_DASHBOARD_OPERATOR}}.
Decision checklist before you ship
- Confirm the entitlement identifier in the dashboard matches the string in code.
- Confirm the product identifier passed to awaitGetProducts matches the store configuration.
- Decide how the UI behaves when customer info is unavailable.
- Verify the banner gate covers every ad placement, not just the main screen.
- Test the purchase dialog on a real Google Play test track.
- Confirm the entitlement updates after purchase and after restore.
- Keep the ad-free upgrade optional so ad revenue continues for non-subscribers.
- Confirm the dashboard operator {{OWNER_DASHBOARD_OPERATOR}} and support terms {{OWNER_SUPPORT_CLAIM}} before publishing.
Frequently asked questions
Do I need a separate product for each billing period?
Yes. The example uses weekly, monthly, and yearly variants under a base identifier. Pass the base identifier to awaitGetProducts so the related products come back as a list, then let the user pick a period.
What is the difference between an entitlement and a product?
A product is the store-level purchase item. An entitlement is the access level your app checks after purchase. Your banner logic should read the entitlement, not the raw product ID, so you can change products without rewriting permission checks.
Can I use the same gate for AdMob and Audience Network?
Yes. Both examples use the same isEntitled boolean in an if/else composable. Only the ad view inside the else branch differs by network.
What happens if the entitlement check fails?
The example checks isActive on the entitlement and treats anything else as not entitled. You should still decide how to handle a failed customer-info request: showing ads is the conservative revenue choice, while hiding ads is the conservative user-experience choice.