How to Integrate the Device Data Collector into Mobile Apps using Android Gradle (Java)

The Gradle build system in Android Studio automates the process of compiling, testing, and packaging your code into an installable app. Use the following instructions to integrate the Device Data Collector into your mobile app.

Integrating the Gradle Dependency Plugin

  1. Add the Jitpack repository to your project’s settings.gradle file.

    For Android Studio IDE, use the following code:

        dependencyResolutionManagement {
               repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
               repositories {
                   google()
                   mavenCentral()
                   ......
                   maven {
                       url 'https://jitpack.io'
                   }
                   ......
               }
        }
        

    If you are using older versions of Android Studio (or a different IDE), add the following code to your build.gradle.

        allprojects {
           repositories {
               ...
               maven {
                   url "https://jitpack.io"
               }
           }
        }
        
  2. In your application’s build.gradle, add the following dependencies using the latest version of the Device Data Collector SDK.

           dependencies {
              ...
              implementation 'com.github.Kount:kount-android-sdk:v5.x.x'
    
              // All dependencies are minimum versions; update to newer versions if necessary.
              implementation "androidx.core:core-ktx:1.0.0"
              implementation "androidx.appcompat:appcompat:1.5.0"
              implementation "com.google.android.instantapps:instantapps:1.0.0"
              implementation "com.google.android.material:material:1.0.0"
              implementation "com.google.android.gms:play-services-base:7.0.0"
              implementation "com.google.code.gson:gson:2.8.9"
              implementation "org.jetbrains.kotlin:kotlin-stdlib:2.1.0"
              implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.0"
        }

    If you get an error, such as unable to resolve dependency for compilepath: :app@debug/compileclasspath: Could not resolve, add the following code snippet to your application’s build.gradle to check the source and target compatibility.

        android {
            ...
            // Configure only for each module that uses Java 8
            // language features (either in its source code or
            // through dependencies).
            compileOptions {
                sourceCompatibility = JavaVersion.VERSION_1_8
                targetCompatibility = JavaVersion.VERSION_1_8
            }
        }
        

    Note

    The Kotlin library is only necessary if your application is written in Java. If your application uses support libraries, then it must be migrated to Android X libraries. Go to Migrate for Android X for more information.

  3. Sync your project with the Gradle files.

  4. After completing the changes in your Android Gradle app, go to How to Invoke the Device Data Collector into Mobile Apps using the Native Android Java SDK to invoke the Device Data Collector from your native Android Java app.

Was this article helpful?
0 out of 0 found this helpful