Skip to content

Connecting and Configuring Android SDK

This section describes the steps for connecting Teleport SDK libraries to your Android project and basic network security configuration.

1. Connecting Libraries

To use the Teleport SDK, you need to add the repository and corresponding dependencies to your project.

Adding the Repository

Before adding dependencies, ensure that the Teleport repository is added to your build.gradle file (project or module level):

groovy
// build.gradle (Project-level) or settings.gradle
repositories {
    maven("https://sdk.teleport.media/artifactory/android/")
}

Adding Dependencies

In your module's build.gradle file (app/build.gradle), add the following dependencies:

  • TeleportCore: for working with core SDK methods.
  • TeleportExoPlayer or TeleportMedia3: for integration with the respective player.
groovy
// build.gradle (Module-level: app/build.gradle)
dependencies {
    implementation("com.teleport:core:0.6.1") // Core SDK

    // Choose one of the options depending on the player used:
    implementation("com.teleport:exoplayer:0.6.1") // For integration with ExoPlayer
    // or
    implementation("com.teleport:media3:0.6.1")    // For integration with Media3
}

Current Versions

Ensure that you are using the current versions of the libraries. Current versions are always indicated in the Android SDK overview.

2. Network Security Configuration

The Teleport SDK may perform network requests to localhost for faster operation. To do this, you need to allow unencrypted traffic for the 127.0.0.1 address through your application's network security settings.

Important

Incorrect network security configuration can lead to problems with connecting and functioning of the Teleport SDK.

Option 1: Using `network_security_config.xml` (recommended)

Create a res/xml/network_security_config.xml file with the following content:

xml
<!-- res/xml/network_security_config.xml -->
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">127.0.0.1</domain>
    </domain-config>
</network-security-config>

Then add a link to this file in the <application> tag of your AndroidManifest.xml:

xml
<!-- AndroidManifest.xml -->
<application
    android:networkSecurityConfig="@xml/network_security_config"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.YourApp">
    <!-- ... other elements ... -->
</application>

Option 2: Using the `android:usesCleartextTraffic` flag (less secure)

Alternatively, you can add the android:usesCleartextTraffic="true" flag directly to the <application> tag of your AndroidManifest.xml. This method is less preferable as it allows all unencrypted traffic for the entire application.

xml
<!-- AndroidManifest.xml -->
<application
    android:usesCleartextTraffic="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.YourApp">
    <!-- ... other elements ... -->
</application>