Skip to content

# Adding to Your Android Studio Project

The Nix Universal SDK is provided as a Maven repository. You may install the library from Maven Central, or the provided `nixrepo.zip` archive can be unzipped and used as a local folder-based repository.

Tip

The latest stable version of the Nix Universal SDK is hosted on Maven Central. It is recommended to install from this source.

## Review the End User License Agreement

Before proceeding, review and accept the End User License Agreement.

## Add dependency from Maven Central

- Ensure that the `mavenCentral()` repository is available to your project. This is typically set in the `dependencyResolutionManagement` section of your project's `settings.gradle` file; it is usually already included by default.

    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()

            // Ensure that Maven Central is included
            mavenCentral()
        }
    }

- Add the `com.nixsensor:universalsdk` dependency to your app level `build.gradle` file

    dependencies {
        // Your existing dependencies here
        // ...

        // Nix Universal SDK
        implementation 'com.nixsensor:universalsdk:4.2.3'
    }

## Optional: Add dependencies for USB support

The Nix Universal SDK can communicate with devices directly attached via USB. This feature relies on the `usb-serial-for-android` library; USB support is automatically enabled once this library is included in your project.

Tip

If you do not require connections to USB attached devices, you can skip this step.

Warning

Prior to Nix Universal SDK version 4.2.0, the `usb-serial-for-android` dependency was included automatically. For SDK version 4.2.0 and later, it is optional and must manually be added to your project if USB support is needed.

- Add the `jitpack.io` repository to your project, typically in the `dependencyResolutionManagement` section of your project's `settings.gradle` file.

    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()

            // Optional: Jitpack repo needed for usb-serial-for-android
            maven { url 'https://jitpack.io' }
        }
    }

- Add the `usb-serial-for-android:v3.8.1` dependency to your app level `build.gradle` file.

    dependencies {
        // Your existing dependencies here
        // ...

        // Nix Universal SDK
        implementation 'com.nixsensor:universalsdk:4.2.3'

        // Optional: Enables USB support in Nix Universal SDK
        implementation 'com.github.mik3y:usb-serial-for-android:v3.8.1'
    }

Tip

Check the Logcat when starting the `DeviceScanner` or when calling `DeviceScanner/listUsbDevices()` directly. If the `usb-serial-for-android` dependency is missing, a error message will be posted stating:

`Could not resolve 'usb-serial-for-android' dependency. USB devices will not be used`

## Next steps

- Activating the SDK License