Android SDK for collecting and reporting device data to MaxMind.
- Android API 27+ (Android 8.1+)
- A recent stable version of Kotlin
- AndroidX libraries
Add the dependency to your app's build.gradle.kts:
dependencies {
implementation("com.maxmind.device:device-sdk:0.3.1")
}dependencies {
implementation 'com.maxmind.device:device-sdk:0.3.1'
}Initialize the SDK in your Application class or main activity:
import com.maxmind.device.DeviceTracker
import com.maxmind.device.config.SdkConfig
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val config = SdkConfig.Builder(123456) // Your MaxMind account ID
.enableLogging(BuildConfig.DEBUG)
.build()
DeviceTracker.initialize(this, config)
}
}lifecycleScope.launch {
DeviceTracker.getInstance().collectAndSend()
.onSuccess { trackingResult ->
// Pass the token to your backend for minFraud integration
sendToBackend(trackingResult.trackingToken)
}
.onFailure { error ->
Log.e("SDK", "Failed to send data", error)
}
}DeviceTracker.getInstance().collectAndSend { result ->
result.onSuccess { trackingResult ->
sendToBackend(trackingResult.trackingToken)
}.onFailure { error ->
Log.e("SDK", "Failed to send data", error)
}
}Kotlin's Result<T> is a value class with limited Java interop. If you need the
tracking token in Java, add a thin Kotlin bridge to your project:
// In your project (e.g., DeviceTrackerBridge.kt)
fun collectAndSend(
tracker: DeviceTracker,
onSuccess: java.util.function.Consumer<String>,
onFailure: java.util.function.Consumer<Throwable>,
) {
tracker.collectAndSend { result ->
result.onSuccess { onSuccess.accept(it.trackingToken) }
.onFailure { onFailure.accept(it) }
}
}// Java caller
collectAndSend(
DeviceTracker.getInstance(),
token -> sendToBackend(token),
error -> Log.e("SDK", "Failed to send data", error)
);After collecting and sending device data, pass the tracking token to the minFraud API to link device data with transactions:
lifecycleScope.launch {
DeviceTracker.getInstance().collectAndSend()
.onSuccess { trackingResult ->
// Pass trackingResult.trackingToken to your backend,
// then include it in the minFraud request's
// /device/tracking_token field
sendToBackend(trackingResult.trackingToken)
}
}val config = SdkConfig.Builder(123456) // Your MaxMind account ID
.serverUrl("https://custom-server.com/api") // Optional: Custom server URL
.enableLogging(true) // Optional: Enable debug logging
.collectionInterval(60_000) // Optional: Auto-collect every 60 seconds
.build()| Builder Method | Type | Default | Description |
|---|---|---|---|
Builder(accountID) |
Int | required | Your MaxMind account ID |
.serverUrl(url) |
String | Default servers | Custom server URL |
.enableLogging(enabled) |
Boolean | false |
Enable debug logging |
.collectionInterval(ms) |
Long | 0 |
Auto-collection interval in milliseconds (0 = disabled) |
The SDK requires the following permissions (automatically included):
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />The SDK includes consumer ProGuard rules. No additional configuration is needed.
See the sample module for a complete working example demonstrating:
- SDK initialization
- Device data collection
- Data transmission
- Error handling
To run the sample app:
./gradlew :sample:installDebug./gradlew :device-sdk:assemble./gradlew :device-sdk:test./gradlew :device-sdk:dokkaHtmlDocumentation will be generated in device-sdk/build/dokka/.
- Fork the repository
- Set up your development environment (see SETUP.md)
- Create a feature branch
- Make your changes
- Run tests and code quality checks
- Submit a pull request
This software is Copyright (c) 2025-2026 by MaxMind, Inc.
This is free software, licensed under the Apache License, Version 2.0 or the MIT License, at your option. Copyright 2025-2026 MaxMind, Inc.
For support, please visit maxmind.com/en/company/contact-us.
If you find a bug or have a feature request, please open an issue on GitHub.