Show your first paywall in an Android app
To show a paywall in an Android app with BillDog, add billdog-compose and billdog-paywall from Maven Central, call BillDog.configure(context, apiKey) in your Application, then call the suspend function BillDog.register(placementId, activity) where the paywall belongs. Google Play Billing runs the purchase, and getCustomerInfo() tells you whether to unlock.
Steps last checked against the SDK source on 15 Nov 2026.
What you'll build
- A Kotlin app that shows a paywall chosen in the dashboard
- Content that unlocks when the
premiumentitlement is active - A Restore Purchases action for users on a new device
What you'll need
- Android Studio, minSdk 21+, JDK 17 and
jvmTarget = "17"in your app module - A free BillDog project (sign up)
- A subscription in Google Play Console (Google Play setup codelab)
1. Add the Gradle dependencies
3 minThe SDK is on Maven Central under the group io.billdog. You need two artifacts: billdog-compose for the SDK and paywall UI, and billdog-paywall for Google Play Billing.
dependencies {
implementation("io.billdog:billdog-compose:1.2.0-beta.1")
implementation("io.billdog:billdog-paywall:1.2.0-beta.1") // Google Play Billing
}billdog-compose does not include Play Billing. Without billdog-paywall, no products load and every purchase fails.
Make sure mavenCentral() is in the repositories block of settings.gradle.kts.
2. Set up the product, paywall and placement
12 minYour app asks BillDog for a placement (a named moment such as onboarding), and the dashboard decides which paywall to show there. That means you can change the paywall later without shipping an app update. Four things need to be connected: a product, an entitlement it grants, an offering that sells it, and a placement that serves the offering's paywall.
- Use the Public Sandbox API Key shown when you created the project. It starts with
bd_public_test_. Didn't save it? The API Keys list shows only a prefix, so make a new one: open Integration & Data → API Keys, click Generate API Key, enter a Key Name, choose Environment: Sandbox and Key Type: Public (Client), then copy the key from the dialog. It is shown only once. Ship only public keys in an app;bd_secret_keys are for servers. - Open Monetization → Products and click New Product. Keep Product Kind: Store. The Product Identifier is BillDog's own ID for the product. Set Product Type to Subscription and choose a Subscription Duration. Put the exact store IDs in App Store Product ID and Play Store Product ID. A product with no ID for a store is not served on that platform. Enable Web Checkout is on by default; its price is only used for Stripe on the web. Products not in the store yet? See App Store setup or Google Play setup.
- Open Monetization → Entitlements, click New Entitlement, use the identifier
premium(with any Display Name), and under Product Mapping tick the product. New projects also come with aproentitlement and a Default Offering; this codelab uses its own. Without this mapping a purchase succeeds but unlocks nothing. - Open Monetization → Offerings, click New Offering, give it an Identifier and Display Name, tick Mark as current offering and click Create Offering. The offering editor opens: click Add Product, tick your product, type a Package Identifier such as
monthly, click Add Package, then Save Changes. - Open Paywalls & Funnels → Create New → Single Paywall, choose Use Template and pick one. In the builder, open the Products panel (the box icon in the left rail) and choose your offering under Offering.
- Templates are designs: their buttons aren't wired to buy anything. Select the main button, and under Tap Actions click Add First Action and choose Purchase. Give the close button (or a secondary button) a Close Paywall action if it has none: publishing refuses a paywall with no way out.
- Click Publish (then Save & Publish). A warning that "nothing on this paywall starts a purchase" means the main button still has no Purchase action. Check the paywall shows Live under Paywalls & Funnels → All Paywalls. An unpublished paywall serves nothing.
- Open Monetization → Placements, click Create Placement, set the Identifier to
onboardingand a Display Name, and click Create. Then click the link icon on the placement's row, tick your offering, tick Default and click Link Offerings. - In the same Create Placement dialog (or later on the placement's page), turn on Requires access and choose
premiumas the Required Entitlement. Subscribers then skip the paywall instead of seeing it again.
Placement identifiers are case-sensitive. A mistyped identifier is created as an empty placement (you'll see it under Placements), and register comes back with a "no paywall configured" error. If nothing shows, see Fix a paywall that doesn't show.
3. Configure the SDK in your Application
3 minConfigure once, in Application.onCreate(), so the SDK is ready before any screen asks for a paywall.
import android.app.Application
import io.billdog.core.BillDog
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
BillDog.configure(this, "bd_public_test_YOUR_KEY")
}
}<application android:name=".MyApplication" ... />BillDog is a Kotlin object in io.billdog.core. To see what the SDK fetches in Logcat while you develop, pass a config: BillDog.configure(this, key, config = BillDogConfig(apiKey = key, enableLogging = true)).
4. Show the paywall for a placement
5 minregister is a suspend function and needs an Activity to present from. It calls your handler with a PlacementResult, which lives in io.billdog.managers.
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.lifecycle.lifecycleScope
import io.billdog.core.BillDog
import io.billdog.managers.PlacementResult
import kotlinx.coroutines.launch
class MainActivity : ComponentActivity() {
private var isPro = false
private fun unlock() {
isPro = true // update your UI here
}
fun showPaywall() {
lifecycleScope.launch {
BillDog.register("onboarding", this@MainActivity) { result ->
when (result) {
is PlacementResult.Entitled,
is PlacementResult.Purchased,
is PlacementResult.Restored -> unlock()
is PlacementResult.Error -> Log.e("BillDog", "Placement failed", result.exception)
else -> Unit // Dismissed, Holdout, OAuthSuccess
}
}
}
}
}From a Composable, get the activity with LocalContext.current as Activity, or with a findActivity() helper if your context is wrapped. With Requires access on, a subscriber gets Entitled and sees nothing. To make a real purchase, see Test real Google Play purchases.
5. Unlock content with the entitlement
3 mingetCustomerInfo() is a suspend function that returns a Kotlin Result. Check it when the app starts so returning subscribers are unlocked.
lifecycleScope.launch {
BillDog.getCustomerInfo()
.onSuccess { info -> isPro = info.hasEntitlement("premium") }
.onFailure { Log.e("BillDog", "Could not read entitlements", it) }
}6. Add Restore Purchases
3 minRestore re-reads the user's Google Play purchases. Refresh customer info afterwards so the UI reflects the result. Like step 4, this runs inside your Activity.
import android.util.Log
import androidx.lifecycle.lifecycleScope
import io.billdog.core.BillDog
import io.billdog.core.RestoreResult
import kotlinx.coroutines.launch
lifecycleScope.launch {
when (val r = BillDog.restorePurchases()) {
is RestoreResult.Restored -> Log.d("BillDog", "Restored ${r.items.size}")
is RestoreResult.Failed -> Log.e("BillDog", "Restore failed: ${r.error}")
}
BillDog.getCustomerInfo(forceRefresh = true)
.onSuccess { isPro = it.hasEntitlement("premium") }
}7. Optional: identify signed-in users
2 minAn anonymous ID is created on configure. Identify users when they sign in so their purchases follow them across devices.
lifecycleScope.launch { BillDog.identify("user_123") }
// On sign-out
BillDog.logOut()Before release, switch to your bd_public_live_ key. Next: run an A/B test on this paywall.