Skip to main content

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.

You get the artifact from Cheggout

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​

ItemValue
Target SDK version35
Minimum SDK version24 (Android 7.0)
Kotlin2.0.0
Android Gradle Plugin (AGP)8.8.0
Gradle8.10.2
JDK17 — required by AGP 8.x
UI toolkitJetpack 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.

AGP 8 and Kotlin 2 both carry migration requirements

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.
  • namespace in build.gradle. AGP 8 removed package from the manifest — declare namespace "com.yourcompany.yourapp" in your app module's android { } block instead.
  • The Compose compiler moved. From Kotlin 2.0 the Compose compiler ships with Kotlin, so you apply the org.jetbrains.kotlin.plugin.compose plugin rather than setting composeOptions.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:

app/build.gradle
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​

build.gradle (project)
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
}

Then apply the plugins in your app module:

app/build.gradle
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:

gradle/wrapper/gradle-wrapper.properties
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
Verify before you go further
./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.

app/build.gradle
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​

GroupWhy the SDK needs it
Compose BOM, ui, material3, runtimeThe SDK's screens are Compose UI. The BOM pins mutually compatible Compose artifact versions.
activity-composeHosting the SDK's composables inside an Activity.
androidx.browserOpening merchant and offer links in a Custom Tab rather than leaving your app.
Retrofit, OkHttp, GsonThe SDK's HTTP client and JSON parsing.
CoilLoading banner, store logo and coupon imagery from URLs.
LottieThe scratch card and reward animations.
Dependency conflicts

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.

MyApplication.kt
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")
}
}

Register the Application class in your manifest if you have not already:

AndroidManifest.xml
<application
android:name=".MyApplication"
... >
channelName must match exactly

channelName 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.

Import package name

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:

  1. Build a debug APK. A missing dependency will surface as an unresolved reference at compile time for the Compose or Retrofit artifacts.
  2. Run the app and confirm onCreate() completes without an exception from init.
  3. Check that your APK grew by roughly the size of the AAR — a fileTree that points at the wrong directory silently includes nothing.

Next​