Launch offer for the first 500 accounts: $10K MTR free for 24 months + $100 credit →
    .io
    Get started
    Android
    Beginner
    31 min

    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 premium entitlement 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 min

    The 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.

    app/build.gradle.kts
    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 min

    Your 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.

    1. 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.
    2. 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.
    3. 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 a pro entitlement and a Default Offering; this codelab uses its own. Without this mapping a purchase succeeds but unlocks nothing.
    4. 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.
    5. 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.
    6. 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.
    7. 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.
    8. Open Monetization → Placements, click Create Placement, set the Identifier to onboarding and 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.
    9. In the same Create Placement dialog (or later on the placement's page), turn on Requires access and choose premium as 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 min

    Configure once, in Application.onCreate(), so the SDK is ready before any screen asks for a paywall.

    MyApplication.kt
    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")
        }
    }
    AndroidManifest.xml
    <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 min

    register is a suspend function and needs an Activity to present from. It calls your handler with a PlacementResult, which lives in io.billdog.managers.

    MainActivity.kt
    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 min

    getCustomerInfo() is a suspend function that returns a Kotlin Result. Check it when the app starts so returning subscribers are unlocked.

    Kotlin
    lifecycleScope.launch {
        BillDog.getCustomerInfo()
            .onSuccess { info -> isPro = info.hasEntitlement("premium") }
            .onFailure { Log.e("BillDog", "Could not read entitlements", it) }
    }

    6. Add Restore Purchases

    3 min

    Restore 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.

    Kotlin
    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 min

    An anonymous ID is created on configure. Identify users when they sign in so their purchases follow them across devices.

    Kotlin
    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.

    Frequently asked questions

    io.billdog:billdog-compose for the SDK and paywall UI, plus io.billdog:billdog-paywall for Google Play Billing. Both are on Maven Central. Without billdog-paywall, products don't load and purchases fail.

    The native Android SDK supports minSdk 21 and needs JDK 17. The Flutter plugin needs minSdk 24, and the React Native bridge defaults to 24.

    The paywall is presented as a screen on top of your app, so the SDK needs an Activity to present from. Call it from an Activity's lifecycleScope, or get the Activity from LocalContext in Compose.

    In the BillDog dashboard under Integration & Data → API Keys. Use the bd_public_test_ key while developing and the bd_public_live_ key in production builds.

    Reference

    Ship it on a free project

    Create a project, grab your SDK key and follow along. Sandbox purchases and data stay separate from production, so test transactions never mix with real revenue.

    We use cookies and process your data to provide our services. By continuing, you agree to our Terms and Privacy Policy.