Android Studio Integration - PhenixRTS Docs

Android Studio SDK Integration

This guide shows how to integrate the Phenix Android SDK into a new project in Android Studio 2022 and higher using Kotlin DSL. The following is a step-by-step approach to integrate the Phenix Android SDK into a new Kotlin DSL project.

Create a New Project (Kotlin DSL)

  1. Download and install Android Studio.

  2. From the File menu in Android Studio, select New > New Project, select any project template, and click Next.

  3. In the New Project popup, name your application, name your package, enter your project save location, select API 23 as the minimum SDK, and select Kotlin DSL (build.gradle.kts) as the build configuration language.

Register a Github token for Phenix SDK access

For Android Studio and Gradle to be able to access the Github-hosted Phenix SDK packages, register an access token to be used in the configuration.

  1. Log into your Github account and go to the tokens page.

  2. Generate a new token which includes the read:packages capability.

  3. Add a line containing a github.token key and the value of the token to your local gradle.properties file.

    • On Mac or Linux, create and/or edit the $HOME/.gradle/gradle.properties file.
    • On Windows, create and/or edit the C:\Users\username\.gradle\gradle.properties file, where username is your Windows user name.
github.token = <personal github access token with read:packages capability>

Add the Phenix SDK to the New Project (Kotlin DSL)

  1. In settings.gradle.kts, modify the dependencyResoluton such that it is able to authenticate with the Github Maven repository, using the token that was configured earlier.
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven("https://maven.pkg.github.com/PhenixRTS/AndroidSDK") {
            credentials {
                username = ""
                password = extra["github.token"].toString()
            }
        }
    }
}
  1. On the app-level, alter the build.gradle.kts to reference the Phenix SDK package we want to import into the project. The example below references 2022.0.3 in the com.phenixrts.android:phenix-sdk-android package.
dependencies {
    implementation("com.phenixrts.android:phenix-sdk-android:2022.0.3")
    ...
}

Start using the Phenix SDK

After completing these steps, com.phenixrts.* classes can be imported into the project.