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.aarfile from our release page.
 
- Add to Your Android Studio Project: - Open your project in Android Studio. 
- Create a - libsdirectory under your app module (if it doesn’t exist) and copy the- ALSDK.aarfile into that folder.
 
- Include the AAR in Your Gradle File: - Open your module-level - build.gradlefile and add the following:- repositories { flatDir { dirs 'libs' } } dependencies { implementation(name: 'ALSDK', ext: 'aar') }
 
- 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:- allprojects { repositories { mavenCentral() // For JitPack: // maven { url 'https://jitpack.io' } } }
 
- Add the Dependency: - In your app module’s - build.gradle, add:- dependencies { implementation 'io.absolutelabs:ALSDK:1.0.12' }
- Replace - com.example:ALSDK:1.0.12with 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 - Applicationclass to initialize the SDK:- // Java Example import android.app.Application; import io.absolutelabs.alsdk.ALSDK; // Adjust package name as needed public class MyApp extends Application { @Override public void onCreate() { super.onCreate(); // Initialize ALSDK ALSDK.getInstance().initialize(this); } }
- For Kotlin: - // Kotlin Example import android.app.Application import io.absolutelabs.alsdk.ALSDK // Adjust package name as needed class MyApp : Application() { override fun onCreate() { super.onCreate() // Initialize ALSDK ALSDK.getInstance().initialize(this) } }
- Don’t Forget: Declare your custom - Applicationclass in your- AndroidManifest.xml:- <application android:name=".MyApp" ... > <!-- Other configurations --> </application>
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:- <manifest ...> <queries> <package android:name="io.metamask.app" /> <!-- Add other packages as needed --> </queries> ... </manifest>
- 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: - ALSDK.getInstance().setExternalId("[email protected]");
- Kotlin Example: - ALSDK.getInstance().externalId = "[email protected]"
Event Tracking
For accurate conversion reporting and analytics, the SDK provides a method to post custom events:
- Java Example: - ALSDK.getInstance().postCustomEvent("Order Successful", "ORDERID-12345");
- Kotlin Example: - ALSDK.getInstance().postCustomEvent("Order Successful", "ORDERID-12345")
Last updated
