ALSDK Android Framework
This guide explains how to integrate the ALSDK SDK into your Android app. You can choose between manual integration (using the prebuilt AAR file) or adding the dependency via Gradle from a Maven repository. For easier updates and maintenance, we recommend using the Gradle dependency method.
Prerequisites
Android Studio: Version 4.0 or later
Minimum API Level: 21 or later
ALSDK.aar: The prebuilt SDK binary (if doing manual integration)
(Optional) Maven Repository: Your ALSDK is hosted on Maven Central, JitPack, or another repository
Integration Options
Manual Integration
Download the SDK:
Obtain the
ALSDK.aar
file from our release page.
Add to Your Android Studio Project:
Open your project in Android Studio.
Create a
libs
directory under your app module (if it doesn’t exist) and copy theALSDK.aar
file into that folder.
Include the AAR in Your Gradle File:
Open your module-level
build.gradle
file and add the following:
Sync and Build:
Sync your Gradle files and build your project to ensure the SDK is correctly integrated.
Gradle Dependency Integration
Add the Repository:
If your ALSDK is hosted on a remote repository (e.g., Maven Central or JitPack), make sure the repository is declared in your project’s root
build.gradle
:
Add the Dependency:
In your app module’s
build.gradle
, add:Replace
com.example:ALSDK:1.0.12
with the actual group, artifact, and version of your SDK.
Sync the Project:
Sync your Gradle files so the dependency is downloaded and integrated automatically.
SDK Setup
For the SDK to be active and functional in your Android app, follow these steps:
SDK Initialization
Initialize in Your Application Class:
Create or update your custom
Application
class to initialize the SDK:For Kotlin:
Don’t Forget: Declare your custom
Application
class in yourAndroidManifest.xml
:
App Detection (Package Queries)
Starting with Android 11 (API level 30), if your app detects the presence of other apps, you must declare the package names you intend to query:
Add Package Queries in
AndroidManifest.xml
:Note: Only list the package names required by your SDK for detecting other apps. Keeping the list lean (around 5 packages) is recommended.
User ID Tracking
To reconcile visitor context and track user profiles, you can pass a user ID to the SDK:
Java Example:
Kotlin Example:
Event Tracking
For accurate conversion reporting and analytics, the SDK provides a method to post custom events:
Java Example:
Kotlin Example:
Last updated