A production-ready Android template for Google Play Billing v9 using Kotlin and DataBinding. Supports one-time purchases and subscriptions with a clean, reusable architecture.
- One-time Purchase (INAPP) & Subscriptions (SUBS).
- Reusable BillingManager with auto-service reconnection.
- Auto-Sync & Restore on app start.
- Material 3 UI with dynamic localized pricing.
- Local Persistence for offline premium status.
- Error Handling for network issues and cancellations.
- Language: Kotlin
- UI: XML, Material 3, DataBinding
- Billing: Google Play Billing Library v9.1.0
- Min SDK: 24
app/
├── billing/
│ ├── BillingManager.kt # Core Google Play Billing operations
│ ├── BillingConstants.kt # Product IDs and constants
│ └── BillingListener.kt # Interface for UI communication
├── data/
│ └── PremiumManager.kt # Local storage for premium status
└── ui/
└── PremiumActivity.kt # Main screen and user interaction
- Clone the repository:
git clone https://github.com/sangidduha/android-play-billing.git
- Configure Google Play Console:
- Create an application in the Play Console.
- Set up the following Product IDs:
- INAPP:
premium_lifetime - SUBS:
premium_weekly,premium_monthly,premium_yearly
- INAPP:
- Upload to Internal Test Track:
- To test billing, the app must be uploaded to a test track (Internal/Alpha/Beta) and have the same version code as your local build.
- License Testing:
- Add your email to the "License Testing" section in the Play Console to perform test purchases without being charged.
This project is designed to be a "plug-and-play" template.
- Copy
BillingManager.kt,BillingConstants.kt, andBillingListener.kt. - Update your Product ID in
BillingConstants.kt. - Call
makePurchase(activity, id, ProductType.INAPP).
- Follow the same steps as above.
- Call
makePurchase(activity, id, ProductType.SUBS, basePlanId).
Professional Android apps should perform a "silent" check for purchases on the Splash Screen or Home Activity. This sets the global premium state before the user encounters ads or locked features. In this sample, this is demonstrated in onBillingLibraryReady.
This project is licensed under the MIT License - see the LICENSE file for details.
Created by Syed Sangid Duha