Follow these steps to integrate the DeviceAssure native SDK into your Android application. The library is written in Kotlin.
Before You Begin
You'll need a DeviceAssure licence key to access the library. To obtain one:
- Visit the DeviceAssure contact form
- Complete the form to request an evaluation
- A member of our sales team will contact you to discuss your requirements
- An evaluation licence will be provided following your consultation
Already have a licence? Log in to access your licence key.
Prerequisites
- Android API 21+ (Android 5.0 Lollipop or higher)
- JDK 11 or higher
Documentation
For comprehensive integration guides, API references, and advanced configuration options, visit our documentation:
Integration Steps
Below outlines the high-level integration steps required. More detailed steps can be found in our DeviceAssure Documentation. A Sample Application with a full code examples is available below.
1. Add Dependencies
Update your build.gradle file with the following:
repositories {
maven {
url "https://java-api.deviceatlas.com/YOUR_LICENCE_KEY"
}
}
dependencies {
implementation "com.deviceassure.android:deviceassure-lib:4.0.0"
}
The library's Kotlin runtime dependencies are resolved automatically from the Maven repository — nothing else to add.
2. Initialize the Library
Initialize DeviceAssure in your Application class:
import com.deviceassure.android.library.DeviceAssure
DeviceAssure.init(applicationContext)
3. Validate the Device
Call checkAsync from a coroutine scope (for example an Activity's lifecycleScope). It suspends until validation completes and returns a ValidationResult:
import com.deviceassure.android.library.DeviceAssure
import com.deviceassure.android.library.ValidationResult
lifecycleScope.launch {
when (val result = DeviceAssure.checkAsync("YOUR_LICENCE_KEY")) {
is ValidationResult.Success -> render(result.response) // JSONObject: result + device properties
is ValidationResult.Error -> showError(result.message) // reason validation could not complete
}
}
render() and showError() are your own methods.
If you'd rather use a callback than the suspending API:
DeviceAssure.check("YOUR_LICENCE_KEY", DeviceAssureCallback(this)) // DeviceAssureCallback implements Callback
4. Handle the Response
A completed validation returns a JSON response (available as result.response), for example:
{
"result": "AUTHENTIC",
"reason": "Device has passed all verification checks",
"isRootedDevice": false,
"isCustomRom": false,
"deviceAtlasProperties": {
"standardisedFullName": "Samsung Galaxy S21 5G",
"yearReleased": 2021,
"deviceId": 62409319
}
}
The result field indicates the validation outcome
Sample Application
- The sample application contains the following:
- Sample application demonstrating how to import and integrate the DeviceAssure Native app library
- Documentation (Javadocs also available online)