Android
Add Dependency
repositories {
mavenCentral()
}Add the dependency to your build.gradle file.
dependencies {
implementation 'io.hackle:hackle-android-sdk:2.66.1'
}ProGuard
If you use ProGuard, obfuscation rules are automatically included in the aar artifact. Otherwise, you must include the rules below.
-keep class io.hackle.android.** { *; }
-keep class io.hackle.sdk.** { *; }Third-party Dependencies
The Hackle Android SDK has the following third-party dependencies.
com.squareup.okhttp3:okhttp:3.12.2
HTTP/HTTPS client
com.google.code.gson:gson:2.8.6
JSON serialization/deserialization
com.google.android.gms:play-services-base:17.3.0
Google Play Services common module
SDK Initialization
You must initialize HackleApp before using the SDK.
An SDK Key is required to initialize
HackleApp.HackleAppis the class that provides methods for using SDK features.You can find the SDK Key in SDK Integration Info on the Hackle Dashboard.
Initialization runs asynchronously, fetching the necessary information from the Hackle server and storing it in the SDK.
Recommended Initialization Strategy: Initialize via Splash Screen
Display a splash screen instead of immediately launching the app, and initialize the SDK. After initialization, close the splash screen via callback so the user can begin interacting with the app.
Inject User on Initialization
You can initialize the SDK with user information included.
If no user information is provided, the user information stored in local storage is used.
If user information is provided, the user information stored in local storage is not used.
If no user is injected and there is no user information in local storage, a user with the Hackle Device ID as the device ID is used.
SDK Initialization Config
You can initialize the SDK with a configuration object.
Configuration Options
exposureEventDedupIntervalMillis*
Removes duplicate exposure events for the same A/B Test or Feature Flag result triggered consecutively by the same user.
Min: 1000 (1 second)
Max: 86400000 (24 hours)
60000 (1 min)
2.7.0+
eventFlushIntervalMillis
The interval at which collected events are sent to the server.
Min: 1000 (1 second)
Max: 60000 (1 minute)
10000 (10 sec)
2.10.0+
pollingIntervalMillis
Periodically updates configuration set in the Dashboard.
Min: 60000 (60 seconds)
-1 (no periodic update)
2.19.0+
automaticScreenTracking
Whether to enable automatic Screen Tracking
true
2.39.0+
automaticAppLifecycleTracking
Whether to enable automatic app start/stop tracking
true
2.64.0+
sessionPolicy
Configures session persistence and expiration conditions.
ALWAYS_NEW_SESSION ,
1800000
2.65.0+
optOutTracking
Whether to enable Opt-out.
false
2.65.0+
evaluationMode
Sets the evaluation mode.
LOCAL
4.0.0+
manualScreenViewDedupEnabled
Whether to deduplicate the screen view event when setCurrentScreen is called with the same screen as the current one. If set to false, $page_view is fired every time the same screen is set again.
true
4.2.0+
sessionTimeoutMillis
(deprecated)
Sets the session timeout duration. Use sessionPolicy instead.
1800000 (30 min)
2.13.0+
Evaluation Mode Configuration
You can choose whether the SDK performs evaluation directly or fetches results that the Hackle server has already evaluated.
If not configured, the SDK uses the default value EvaluationMode.LOCAL (local evaluation).
Session Policy Configuration
You can configure session persistence and expiration conditions using the session policy.
Get Instance
After initialization, you can retrieve the HackleApp instance with the code below.
Refresh Dashboard Configuration
After initialization, you can explicitly refresh Dashboard configuration when needed.
Last updated