Android SDK installation
By the end of this page your app compiles against the Cheggout AAR and calls
CheggoutApplication.init() once at process start. That is everything the SDK needs before you can
launch it or call any of its data methods.
The Android SDK is not published to Maven Central, JitPack or any public repository. Cheggout
supplies the .aar file directly during onboarding, along with your channelName. If you do not
have it yet, start with Onboarding.
Requirements
| Item | Value |
|---|---|
| Target SDK version | 35 |
| Minimum SDK version | 24 (Android 7.0) |
| Kotlin | 2.0.0 |
| Android Gradle Plugin (AGP) | 8.8.0 |
| Gradle | 8.10.2 |
| JDK | 17 — required by AGP 8.x |
| UI toolkit | Jetpack Compose — the SDK renders with Compose and requires the Compose runtime on your classpath |
A minSdk of 24 means the SDK will not install on Android 6.0 or older. If your app supports lower
API levels, guard your launch entry point behind a version check rather than lowering the SDK's
requirement.
If you are coming from AGP 7 or Kotlin 1.x, three things change and each one fails the build until you address it:
- JDK 17. AGP 8.x will not run on JDK 11. Set your Gradle JDK to 17.
namespaceinbuild.gradle. AGP 8 removedpackagefrom the manifest — declarenamespace "com.yourcompany.yourapp"in your app module'sandroid { }block instead.- The Compose compiler moved. From Kotlin 2.0 the Compose compiler ships with Kotlin, so you
apply the
org.jetbrains.kotlin.plugin.composeplugin rather than settingcomposeOptions.kotlinCompilerExtensionVersion. The SDK renders with Compose, so this is not optional.
These are Kotlin and AGP platform requirements, not Cheggout-specific ones — but the SDK will not compile without them.
Step 1 — Add the AAR
Copy the .aar file Cheggout gave you into your app module's libs folder:
your-app/
app/
libs/
cheggout-sdk.aar ← the file Cheggout supplied
build.gradle
build.gradle
Then tell Gradle to pick up everything in that folder:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
}
Using fileTree rather than naming the file means a version bump is a file replacement, not a build
script edit. Commit the AAR to your repository or to your artifact store so CI can build without a
manual step.
Step 2 — Configure the project-level Gradle file and the Gradle version
Two files matter here, and getting only one of them right is the usual cause of a failed first build: the plugin versions in your project-level Gradle file, and the Gradle distribution itself in the wrapper properties. AGP 8.8.0 requires Gradle 8.10.2 or newer, so these move together.
The project-level Gradle file
- Plugins DSL (recommended)
- Legacy buildscript block
plugins {
id 'com.android.application' version '8.8.0' apply false
id 'org.jetbrains.kotlin.android' version '2.0.0' apply false
// Required from Kotlin 2.0 — the Compose compiler is no longer configured through AGP.
id 'org.jetbrains.kotlin.plugin.compose' version '2.0.0' apply false
}
buildscript {
ext.kotlin_version = '2.0.0'
dependencies {
classpath 'com.android.tools.build:gradle:8.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:compose-compiler-gradle-plugin:$kotlin_version"
}
}
Then apply the plugins in your app module:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.compose'
}
android {
namespace 'com.yourcompany.yourapp' // AGP 8 requires this
compileSdk 35
defaultConfig {
minSdk 24
targetSdk 35
}
buildFeatures {
compose true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
}
The Gradle version
Set the Gradle distribution in the wrapper properties — this is a separate file from any
build.gradle, and updating the AGP version alone will not change it:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
Or from the command line, which also updates the wrapper scripts:
./gradlew wrapper --gradle-version 8.10.2
./gradlew --version
Confirm it reports Gradle 8.10.2 and JVM 17. If either is wrong, fix it now — every error later in this guide will be a symptom of it.
Step 3 — Add the SDK's dependencies
The AAR does not carry transitive dependency metadata, so you declare its dependencies yourself.
Add all of the following to your app module. Omitting one produces a NoClassDefFoundError at
runtime rather than a compile error, so add the complete set.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
// Compose
implementation platform("androidx.compose:compose-bom:2024.04.01")
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation "androidx.compose.material3:material3"
implementation "androidx.compose.runtime:runtime:1.10.6"
implementation "androidx.compose.runtime:runtime-livedata:1.10.2"
implementation "androidx.constraintlayout:constraintlayout-compose:1.1.0"
// AndroidX
implementation "androidx.core:core-ktx:1.10.1"
implementation "androidx.activity:activity-compose:1.10.1"
implementation "androidx.constraintlayout:constraintlayout:2.0.1"
implementation "androidx.browser:browser:1.8.0"
implementation "androidx.recyclerview:recyclerview:1.3.2"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2"
// Networking and serialisation
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation "com.squareup.okhttp3:okhttp:4.12.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.12.0"
implementation "com.google.code.gson:gson:2.9.1"
// Imagery and animation
implementation "io.coil-kt:coil-compose:2.6.0"
implementation "com.airbnb.android:lottie-compose:6.4.0"
}
What each group is for
| Group | Why the SDK needs it |
|---|---|
Compose BOM, ui, material3, runtime | The SDK's screens are Compose UI. The BOM pins mutually compatible Compose artifact versions. |
activity-compose | Hosting the SDK's composables inside an Activity. |
androidx.browser | Opening merchant and offer links in a Custom Tab rather than leaving your app. |
| Retrofit, OkHttp, Gson | The SDK's HTTP client and JSON parsing. |
| Coil | Loading banner, store logo and coupon imagery from URLs. |
| Lottie | The scratch card and reward animations. |
Your app almost certainly already uses OkHttp, Gson or Compose. Gradle will resolve to the highest requested version, which is usually fine. If you hit a runtime incompatibility, pin the version the SDK expects for that one artifact rather than downgrading your whole app, and raise it with Cheggout support.
Step 4 — Initialise in your Application class
The SDK holds process-wide state — your channel identity and its HTTP stack — so it is initialised
once in Application.onCreate(), not per Activity.
- Kotlin
- Java
import android.app.Application
import com.cheggout.integration.CheggoutApplication
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// channelName is the identifier Cheggout issued to you during onboarding.
CheggoutApplication.init(this, "YOURCHANNEL")
}
}
import android.app.Application;
import com.cheggout.integration.CheggoutApplication;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
CheggoutApplication.Companion.init(this, "YOURCHANNEL");
}
}
Register the Application class in your manifest if you have not already:
<application
android:name=".MyApplication"
... >
channelName must match exactlychannelName is the same identifier as the CHANNELID your backend sends in the
signed envelope, and it is matched case-sensitively.
A mismatch does not fail at init — it fails later, as an SDK that loads to a blank page because the
session it was handed cannot be verified against the channel.
TBD The exact package name for CheggoutApplication and the helper classes is not
stated in the integration document. Use the import path in the sample project Cheggout ships with
the AAR; the snippets here use a placeholder path.
Verify the install
Before writing any launch code, confirm the SDK is on the classpath and initialising:
- Build a debug APK. A missing dependency will surface as an unresolved reference at compile time for the Compose or Retrofit artifacts.
- Run the app and confirm
onCreate()completes without an exception frominit. - Check that your APK grew by roughly the size of the AAR — a
fileTreethat points at the wrong directory silently includes nothing.
Next
- Launching the SDK — minting a session and calling
launchCheggout. - SDK methods — banners, stores, cashback points and scratch cards.
- Callbacks and notifications — the listener interfaces and push notification setup.
GenerateSessionInfoV2— the server call your backend makes before launch.