Skip to content

Sample Application

A sample application is included in the package demonstrating how to integrate and use the DeviceAssure library in an Android application.


Prerequisites

  • JDK version 11
  • Android SDK with API level 21 or higher
  • Gradle (or use the included Gradle wrapper)
  • A valid DeviceAssure licence key
  • An Android device or emulator for testing

Setup Steps

1. Extract the Sample Application

Extract the contents of the DeviceAssure SDK zip archive to your desired location.

2. Configure Your Licence Key

The sample application requires your DeviceAssure licence key to function. This must be configured before building.

Locate the application.properties file in app/src/main/assets/application.properties and add your licence key:

licence-key=<LICENCE_KEY>

3. Configure Build Gradle with Licence Key

In order to download the DeviceAssure library from the DeviceAtlas Maven repository, you will also need to add your licence key to the build.gradle at the project level.

Edit the build.gradle file located in the root of the project and find the placeholder text:

licence = "Please enter your DeviceAssure licence key here"

Replace it with your actual licence key.

4. Build the Application

From the project root directory, build the application using Gradle:

# Using Gradle wrapper (recommended)
./gradlew assembleDebug

# Or for Windows
gradlew.bat assembleDebug

The APK will be generated in app/build/outputs/apk/debug/

5. Install on Device or Emulator

Option 1: Using Gradle

./gradlew installDebug

Option 2: Using ADB

# Install APK directly
adb install app/build/outputs/apk/debug/app-debug.apk

# Launch the app
adb shell am start -n com.deviceassure.android.example/.activity.MainActivity

Option 3: Using your IDE

Open the project in Android Studio and build and run the application using the IDE's build tools.


Granting Permissions

On Android 6.0 (API 23) and higher, dangerous permissions must be requested at runtime. The sample app requires the Phone State permission to collect TAC data for device validation on Android 9 and below.

Note: On Android 10 and higher, TAC collection does not require the Phone State permission, so no permission prompt is needed on these devices.

Important: The DeviceAssure library checks permission status but does not request permissions itself. Host applications should request any required permissions before calling DeviceAssure.check() or DeviceAssure.getData().


Verifying the Setup

Once the app is running:

  • The app should successfully initialise the DeviceAssure library
  • Device data collection will begin automatically
  • Results will be displayed in the app's UI
  • Monitor logcat for detailed logs:
adb logcat | grep -i deviceassure

Troubleshooting

If you encounter errors, verify that:

  • Your licence key is correctly configured in both the build.gradle and application.properties files
  • All required permissions are granted on the device
  • Your device/emulator meets the minimum API level requirement (API 21)
  • You have a stable internet connection for the application to communicate with the DeviceAssure service

See Also