Skip to content

1.1 Integrate Maven Artifact

This tutorial will guide you through the process of integrating the NIMMSTA maven dependency into your project.

Requirements

  • The minimum SDK level for Android devices is 21, recommended is 23+.
  • You should already have credentials for the NIMMSTA Maven Repo
  • Make sure to download and install the latest firmware bundle for this release from the B2B Portal
  • You should use Gradle 6.5+

The NIMMSTA Maven Repo

To download the artifacts, you need access credentials to the NIMMSTA Repo. You can get access credentials by asking your service partner or contact person at NIMMSTA.

First add the Kotlin Gradle Plugin.

buildscript {

    /* ... */

    repositories {
        /* ... */
    }

    dependencies {
        /* ... */

        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10" // You can use the latest version
    }
}
buildscript {

    /* ... */

    repositories {
        /* ... */
    }

    dependencies {
        /* ... */

        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10") // You can use the latest version
    }
}

Settings

Next add the NIMMSTA Maven Repository to the settings. Use your NIMMSTA access credentials.

repositories {
    /* ... */
    google()
    mavenCentral()
    maven {
        url 'https://maven.goma-cms.org/repository/nimmsta-core-release/'
        credentials {
            username = "yourusername"
            password = "yourpassword"
        }
        authentication {
            basic(BasicAuthentication)
        }
        metadataSources {
            mavenPom()
            artifact()
        }
    }
}
/* ... */
repositories {
    /* ... */
    google()
    mavenCentral()
    maven {
        url = uri("https://maven.goma-cms.org/repository/nimmsta-core-release/")
        credentials {
            username = "yourusername"
            password = "yourpassword"
        }
        metadataSources {
            mavenPom()
            artifact()
        }
    }
}
/* ... */

Android Maven Dependency

After you configured the repository, you can include the artifact in your build system. Please also integrate the kotlin plugin, so that the dependency management can select the correct artifacts.

Warning

You also need the Kotlin plugin if you are using Java for your app!

Note

If your IDE gives you a hint that a new version of the shared-android or android projects is available you can download the newest version.

plugins {
    /* ... */
    id 'kotlin-android'
}

dependencies {
    /* ... */
    api("com.nimmsta.core:shared-android:6.0.+@aar")
    api("com.nimmsta.core:android:6.0.+@aar") {
        transitive = true
        changing = true
    }
}
plugins {
    /* ... */
    id("kotlin-android")
}

dependencies {
    api("com.nimmsta.core:shared-android:6.0.+@aar")
    api("com.nimmsta.core:android:6.0.+@aar") {
        isTransitive = true
        isChanging = true
    }
}

Android Packaging Options

To prevent problems when packaging the application, we need to add packaging options due to one dependency:

android {
    /* ... */
    packagingOptions {
        exclude 'META-INF/*.kotlin_module'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/io.netty.versions.properties'
    }

    /* needed in case of build errors depending on Android Target */
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
android {
    /* ... */
    packagingOptions {
        exclude("META-INF/*.kotlin_module")
        exclude("META-INF/DEPENDENCIES")
        exclude("META-INF/INDEX.LIST")
        exclude("META-INF/io.netty.versions.properties")
    }
    /* needed in case of build errors depending on Android Target */
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}

Enable Android X

In order to use the UI of our activites, you have to enable Android X:

android.useAndroidX=true

Use AppCompat Theme

Please use an AppCompat theme for your application, for example:

<application
            ...
            android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<!-- ... -->
</application>

Optional: Remove unused packages

As the android package contains dependencies not necessarily needed for your app, you can exclude the following dependencies:

plugins {
    /* ... */
    id 'kotlin-android'
}

dependencies {
    /* ... */
    api("com.nimmsta.core:shared-android:6.0.+@aar")
    api("com.nimmsta.core:android:6.0.+@aar") {
        transitive = true
        changing = true

        exclude group: 'io.ktor', module: 'ktor-server-core'
        exclude group: 'io.ktor', module: 'ktor-server-netty'
        exclude group: 'io.ktor', module: 'ktor-server-websockets'
        exclude group: 'io.ktor', module: 'ktor-server-cors'

        exclude group: 'io.ktor', module: 'ktor-client-android'
    }
}