Implementing in-app subscriptions and products using Jetpack Compose

Daniel Atitienei
8 min readJul 4, 2023

Hey! Take your coffee ☕️ and see how to implement in-app subscriptions and products using Jetpack Compose.

Introduction

Before starting, you need to know that it is a must to have the application in the Google Play Console.

Setup

Go ahead to :app/build.gradle.kts and add this dependency.

dependencies {
// Billing
val billingVersion = "6.0.1"
implementation("com.android.billingclient:billing-ktx:$billingVersion")

// Lifecycle
// To use collectAsStateWithLifecycle
val lifecycleVersion = "2.6.1"
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-runtime-compose:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion")
}

Before jumping into writing some code, we have to go to AndroidManifest.xml and enable the billing in our app. Add this above the application tag.

<uses-permission android:name="com.android.vending.BILLING" />

Now we need to open the Google Play Console and create a new application. After that, we need to create a closed testing channel on which we will release the application…

--

--