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

The Gradle build system in Android Studio makes it easy to include external binaries or other library modules to your build as dependencies. The dependencies are located on your machine or in a remote repository. Any transitive dependencies declared are automatically included.

Integrating the Gradle Dependency Plugin

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

    For the current 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 he following code to your build.gradle file.

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

    dependencies {
        ...
        implementation 'com.github.Kount:kount-android-sdk:v5.x.x'
        
        // All these versions are minimums; you can update to newer ones.
        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"
    }

    Note

    If your application uses Support libraries, then it must be migrated to Android X libraries. Refer to Migrate for Android X for more information.

    If you get an error like unable to resolve dependency for compilepath: :app@debug/compileclasspath: Could not resolve, check that the source and target compatibility are set by adding the following lines of code in your application’s build.gradle.

        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
            }
    
            kotlinOptions {
                jvmTarget = '1.8'
            }
        }
        
  3. Sync your project with the Gradle files.

  4. Once you have integrated the Android Gradle, go to How to Invoke the Device Data Collector into Mobile Apps using the Native Android Kotlin SDK to invoke the Data Device Collector from your native Android Kotlin app.

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