Install & configure the Adapty Kotlin Multiplatform SDK
Adapty SDK includes two key modules for seamless integration into your mobile app:
- Core Adapty: This essential SDK is required for Adapty to function properly in your app.
- AdaptyUI: This module is needed if you use the Adapty Paywall Builder, a user-friendly, no-code tool for easily creating cross-platform paywalls.
Want to see a real-world example of how Adapty SDK is integrated into a mobile app? Check out our sample app, which demonstrates the full setup, including displaying paywalls, making purchases, and other basic functionality.
Adapty supports Google Play Billing Library up to 7.x. Support for Billing Library 8.0.0 (released 30 June, 2025) is planned.
Install Adapty SDK via Gradle
Adapty SDK installation with Gradle is required for both Android and iOS apps.
Choose your dependency setup method:
- Standard Gradle: Add dependencies to your module-level
build.gradle
- If your project uses
.gradle.kts
files, add dependencies to your module-levelbuild.gradle.kts
- If you use version catalogs, add dependencies to your
libs.versions.toml
file and then, reference it inbuild.gradle.kts
- module-level build.gradle
- module-level build.gradle.kts
- Versions library
kotlin {
sourceSets {
commonMain {
dependencies {
implementation libs.adapty.kmp
}
}
}
}
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation(libs.adapty.kmp)
}
}
}
}
// libs.versions.toml
[versions]
..
adapty-kmp = "<the latest SDK version>"
[libraries]
..
adapty-kmp = { module = "io.adapty:adapty-kmp", version.ref = "adapty-kmp" }
// build.gradle.kts
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation(libs.adapty.kmp)
}
}
}
}
If you get a Maven-related error, make sure that you have mavenCentral()
in your Gradle scripts.
The instruction on how to add it
If your project doesn't have dependencyResolutionManagement
in your settings.gradle
, add the following to your top-level build.gradle
at the end of repositories:
allprojects {
repositories {
...
mavenCentral()
}
}
Otherwise, add the following to your settings.gradle
in repositories
of dependencyResolutionManagement
section:
dependencyResolutionManagement {
...
repositories {
...
google()
mavenCentral()
}
}
Activate Adapty SDK
Basic setup
Add the initialization as early as possible—typically in your shared Kotlin code for both platforms.
import com.adapty.kmp.Adapty
import com.adapty.kmp.models.AdaptyConfig
val config = AdaptyConfig
.Builder("PUBLIC_SDK_KEY")
.build()
Adapty.activate(configuration = config)
.onSuccess {
Log.d("Adapty", "SDK initialised")
}
.onError { error ->
Log.e("Adapty", "Adapty init error: ${error.message}")
}
To get your Public SDK Key:
- Go to Adapty Dashboard and navigate to App settings → General.
- From the Api keys section, copy the Public SDK Key (NOT the Secret Key).
- Replace
"YOUR_PUBLIC_SDK_KEY"
in the code.
- Make sure you use the Public SDK key for Adapty initialization, the Secret key should be used for server-side API only.
- SDK keys are unique for every app, so if you have multiple apps make sure you choose the right one.
Activate AdaptyUI module of Adapty SDK
If you plan to activate the AdaptyUI module to use the Adapty Paywall Builder, make sure to set .withActivateUI(true)
in your configuration.
important In your code, you must activate the core Adapty module before activating AdaptyUI.
import com.adapty.kmp.Adapty
import com.adapty.kmp.models.AdaptyConfig
import com.adapty.kmp.models.AdaptyLogLevel
val config = AdaptyConfig
.Builder("PUBLIC_SDK_KEY")
.withActivateUI(true) // true for activating the AdaptyUI module
.build()
Adapty.activate(configuration = config)
.onSuccess {
Log.d("Adapty", "SDK initialised")
}
.onError { error ->
Log.e("Adapty", "Adapty init error: ${error.message}")
}
Configure Proguard (Android)
Before launching your app in the production, you might need to add -keep class com.adapty.** { *; }
to your Proguard configuration.
Optional setup
Logging
Set up the logging system
Adapty logs errors and other important information to help you understand what is going on. There are the following levels available:
Level | Description |
---|---|
AdaptyLogLevel.NONE | Nothing will be logged. Default value |
AdaptyLogLevel.ERROR | Only errors will be logged |
AdaptyLogLevel.WARN | Errors and messages from the SDK that do not cause critical errors, but are worth paying attention to will be logged. |
AdaptyLogLevel.INFO | Errors, warnings, and various information messages will be logged. |
AdaptyLogLevel.VERBOSE | Any additional information that may be useful during debugging, such as function calls, API queries, etc. will be logged. |
You can set the log level in your app before configuring Adapty:
import com.adapty.kmp.models.AdaptyConfig
import com.adapty.kmp.models.AdaptyLogLevel
val config = AdaptyConfig
.Builder("PUBLIC_SDK_KEY")
.withLogLevel(AdaptyLogLevel.VERBOSE) // recommended for development
.build()
Data policies
Disable IP address collection and sharing
When activating the Adapty module, set ipAddressCollectionDisabled
to true
to disable user IP address collection and sharing. The default value is false
.
Use this parameter to enhance user privacy, comply with regional data protection regulations (like GDPR or CCPA), or reduce unnecessary data collection when IP-based features aren't required for your app.
import com.adapty.kmp.models.AdaptyConfig
val config = AdaptyConfig
.Builder("PUBLIC_SDK_KEY")
.withIpAddressCollectionDisabled(true)
.build()
Disable advertising ID collection and sharing
When activating the Adapty module, set appleIdfaCollectionDisabled
(iOS) or googleAdvertisingIdCollectionDisabled
(Android) to true to disable the collection of advertising identifiers. The default value is false.
Use this parameter to comply with App Store/Play Store policies, avoid triggering the App Tracking Transparency prompt, or if your app does not require advertising attribution or analytics based on advertising IDs.
import com.adapty.kmp.models.AdaptyConfig
val config = AdaptyConfig
.Builder("PUBLIC_SDK_KEY")
.withGoogleAdvertisingIdCollectionDisabled(true) // Android only
.withAppleIdfaCollectionDisabled(true) // iOS only
.build()
Set up media cache configuration for AdaptyUI
By default, AdaptyUI caches media (such as images and videos) to improve performance and reduce network usage. You can customize the cache settings by providing a custom configuration.
Use mediaCache
to override the default cache settings:
import com.adapty.kmp.models.AdaptyConfig
val config = AdaptyConfig
.Builder("PUBLIC_SDK_KEY")
.withMediaCacheConfiguration(
AdaptyConfig.MediaCacheConfiguration(
memoryStorageTotalCostLimit = 200 * 1024 * 1024, // 200 MB
memoryStorageCountLimit = Int.MAX_VALUE,
diskStorageSizeLimit = 200 * 1024 * 1024 // 200 MB
)
)
.build()