Android - Adapty SDK Installation and configuration
Adapty comprises two crucial SDKs for seamless integration into your mobile app:
- Core AdaptySDK: This is a fundamental, mandatory SDK necessary for the proper functioning of Adapty within your app.
- AdaptyUI SDK: This optional SDK becomes necessary if you use the Adapty Paywall builder: a user-friendly, no-code tool for easily creating cross-platform paywalls. These paywalls are built in a visual constructor right in our dashboard, run entirely natively on the device, and require minimal effort from you to create something that performs well.
You can install Adapty SDK via Gradle.
Go through the release checklist before releasing your app
Before releasing your application, make sure to carefully review the Release Checklist thoroughly. This checklist ensures that you've completed all necessary steps and provides criteria for evaluating the success of your integration.
- Adapty SDK v3.x+ (current)
- Up to v2.x (legacy)
Install via Gradle
- module-level build.gradle
- module-level build.gradle.kts
- version catalog
dependencies {
...
implementation platform('io.adapty:adapty-bom:3.1.2')
implementation 'io.adapty:android-sdk'
implementation 'io.adapty:android-ui'
}
dependencies {
...
implementation(platform("io.adapty:adapty-bom:3.1.2"))
implementation("io.adapty:android-sdk")
implementation("io.adapty:android-ui")
}
//libs.versions.toml
[versions]
..
adaptyBom = "3.1.2"
[libraries]
..
adapty-bom = { module = "io.adapty:adapty-bom", version.ref = "adaptyBom" }
adapty = { module = "io.adapty:android-sdk" }
adapty-ui = { module = "io.adapty:android-ui" }
//module-level build.gradle.kts
dependencies {
...
implementation(platform(libs.adapty.bom))
implementation(libs.adapty)
implementation(libs.adapty.ui)
}
If the dependency is not being resolved, please 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 {
...
mavenCentral()
}
}
Configure Proguard
You should add -keep class com.adapty.** { *; }
to your Proguard configuration.
Configure Adapty SDK
Add the following to your Application
class:
- Kotlin
- Java
override fun onCreate() {
super.onCreate()
Adapty.activate(
applicationContext,
AdaptyConfig.Builder("PUBLIC_SDK_KEY")
.withObserverMode(false) //default false
.withCustomerUserId(customerUserId) //default null
.withIpAddressCollectionDisabled(false) //default false
.build()
)
}
@Override
public void onCreate() {
super.onCreate();
Adapty.activate(
applicationContext,
new AdaptyConfig.Builder("PUBLIC_SDK_KEY")
.withObserverMode(false) //default false
.withCustomerUserId(customerUserId) //default null
.withIpAddressCollectionDisabled(false) //default false
.build()
);
}
Configurational options:
Parameter | Presence | Description |
---|---|---|
PUBLIC_SDK_KEY | required | The key you can find in the Public SDK key field of your app settings in Adapty: App settings-> General tab -> API keys subsection. Make sure you use the Public SDK key for Adapty initialization, the Secret key should be used for server-side API only. |
observerMode | optional | A boolean value that controls Observer mode. Turn it on if you handle purchases and subscription status yourself and use Adapty for sending subscription events and analytics. The default value is 🚧 When running in Observer mode, Adapty SDK won't close any transactions, so make sure you're handling it. |
customerUserId | optional | An identifier of the user in your system. We send it in subscription and analytical events, to attribute events to the right profile. You can also find customers by customerUserId in the Profiles and Segments menu. If you don't have a user ID at the time of Adapty initialization, you can set it later using .identify() method. Read more in the Identifying users section. |
ipAddressCollectionDisabled | optional | A boolean parameter. Set to Parameter works with |
SDK keys are unique for every app, so if you have multiple apps make sure you choose the right one.
Please consult the compatibility table below to choose the correct pair of Adapty SDK and AdaptyUI SDK.
Adapty SDK version | AdaptyUI version |
---|---|
2.7.x–2.9.x | 2.0.x |
2.10.0 | 2.1.2 |
2.10.2 | 2.1.3 |
2.11.0 - 2.11.3 | 2.11.0 - 2.11.2 |
2.11.5 | 2.11.3 |
You can install Adapty SDK via Gradle.
Go through release checklist before releasing your app
Before releasing your application, make sure to carefully review the Release Checklist thoroughly. This checklist ensures that you've completed all necessary steps and provides criteria for evaluating the success of your integration.
Install via Gradle
- module-level build.gradle
- module-level build.gradle.kts
- version catalog
dependencies {
...
implementation 'io.adapty:android-sdk:2.11.5'
implementation 'io.adapty:android-ui:2.11.3'
}
dependencies {
...
implementation("io.adapty:android-sdk:2.11.5")
implementation("io.adapty:android-ui:2.11.3")
}
//libs.versions.toml
[versions]
..
adapty = "2.11.5"
adaptyUi = "2.11.3"
[libraries]
..
adapty = { group = "io.adapty", name = "android-sdk", version.ref = "adapty" }
adapty-ui = { group = "io.adapty", name = "android-ui", version.ref = "adaptyUi" }
//module-level build.gradle.kts
dependencies {
...
implementation(libs.adapty)
implementation(libs.adapty.ui)
}
If the dependency is not being resolved, please 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 {
...
mavenCentral()
}
}
Configure Proguard
You should add -keep class com.adapty.** { *; }
to your Proguard configuration.
Configure Adapty SDK
Add the following to your Application
class:
- Kotlin
- Java
override fun onCreate() {
super.onCreate()
Adapty.activate(
applicationContext,
AdaptyConfig.Builder("PUBLIC_SDK_KEY")
.withObserverMode(false) //default false
.withCustomerUserId(customerUserId) //default null
.withIpAddressCollectionDisabled(false) //default false
.build()
)
//OR
//the method is deprecated since Adapty SDK v2.10.5
Adapty.activate(applicationContext, "PUBLIC_SDK_KEY", observerMode = false, customerUserId = "YOUR_USER_ID")
}
@Override
public void onCreate() {
super.onCreate();
Adapty.activate(
applicationContext,
new AdaptyConfig.Builder("PUBLIC_SDK_KEY")
.withObserverMode(false) //default false
.withCustomerUserId(customerUserId) //default null
.withIpAddressCollectionDisabled(false) //default false
.build()
);
//OR
//the method is deprecated since Adapty SDK v2.10.5
Adapty.activate(getApplicationContext(), "PUBLIC_SDK_KEY", false, "YOUR_USER_ID");
}
Configurational options:
Parameter | Presence | Description |
---|---|---|
PUBLIC_SDK_KEY | required | The key you can find in the Public SDK key field of your app settings in Adapty: App settings-> General tab -> API keys subsection. Make sure you use the Public SDK key for Adapty initialization, the Secret key should be used for server-side API only. |
observerMode | optional | A boolean value that controls Observer mode. Turn it on if you handle purchases and subscription status yourself and use Adapty for sending subscription events and analytics. The default value is 🚧 When running in Observer mode, Adapty SDK won't close any transactions, so make sure you're handling it. |
customerUserId | optional | An identifier of the user in your system. We send it in subscription and analytical events, to attribute events to the right profile. You can also find customers by customerUserId in the Profiles and Segments menu. If you don't have a user ID at the time of Adapty initialization, you can set it later using .identify() method. Read more in the Identifying users section. |
IpAddressCollectionDisabled | optional | A boolean parameter. Set to Parameter works with |
SDK keys are unique for every app, so if you have multiple apps make sure you choose the right one.
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.
- Kotlin
- Java
Adapty.logLevel = AdaptyLogLevel.VERBOSE
Adapty.setLogLevel(AdaptyLogLevel.VERBOSE);
Redirect the logging system messages
If you for some reason need to send messages from Adapty to your system or save them to a file, you can override the default behavior:
- Kotlin
- Java
Adapty.setLogHandler { level, message ->
//handle the log
}
Adapty.setLogHandler((level, message) -> {
//handle the log
});