Add the Android SDK

Download the SDK and add the SDK to your Android project.


To add a player to your app, you must import the JW Player SDK for Android and then configure your project. You can download the Android SDK using either the Gradle or Local approaches listed below.


ApproachNotes
Gradle
(Recommended)
• Gradle will download the SDK’s core and optional modules for you.
• ProGuard is automatically configured.
• An existing app is required.
Local• The JW Player Android SDK must be downloaded and unzipped.
• Core and optional modules must be imported manually.
• ProGuard must be configured.
• An existing app is required.

If you have any problems completing any of these tasks and have a valid JW Player license, please log a support ticket for assistance.



Gradle

Import the SDK into your project with Gradle

  1. From within Android Studio, open your app.
  2. In the project build.gradle file, add the JW Player Maven repository: https://mvn.jwplayer.com/content/repositories/releases/.
allprojects {
    repositories {
    ...
        maven {
            url 'https://mvn.jwplayer.com/content/repositories/releases/'
        }
    }
}
  1. In the app build.gradle file:

    • Add the JW Player and Android dependencies. When prompted by Android Studio, update the dependency versions.

    • Configure compileOptions to support Java 8 language support.
ext.jwPlayerVersion = '4.0.0'
ext.exoplayerVersion = '2.14.0'

dependencies {
    ...
    // JWPlayer SDK
    implementation "com.jwplayer:jwplayer-core:$jwPlayerVersion"
    implementation "com.jwplayer:jwplayer-common:$jwPlayerVersion"
    
    // ExoPlayer dependencies
    implementation "com.google.android.exoplayer:exoplayer-core:$exoplayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-dash:$exoplayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-hls:$exoplayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$exoplayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-ui:$exoplayerVersion"

    // JW Player Native UI dependencies
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
    implementation 'com.android.volley:volley:1.2.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'

    // your app’s other dependencies
}
android {
    defaultConfig {
        ...
        minSdkVersion 21
        multiDexEnabled true
    }
    ...
    compileOptions {
        sourceCompatibility = '1.8'
        targetCompatibility = '1.8'
    }
}
  1. In the gradle.properties file, set android.useAndroidX and android.enableJetifier to true. These plugin files enable you to use androidx-namespaced libraries in your project.

📘

If you are using a current version of Android Studio, the gradle.properties file should already contain these settings.

# Project-wide Gradle settings.

android.useAndroidX=true
android.enableJetifier=true
  1. Sync Gradle.

You have imported the JW Player SDK for Android into your project. You can now configure ProGuard and configure the manifest.



Local

Download the Android SDK .zip file

  1. From your Player Downloads & Keys page, scroll down to the Downloads section.

👍

IMPORTANT

If you have more than one property in your account, select the property from the dropdown menu at the top of the page. Each property has a unique set of license keys.

  1. In the Downloads section, select a VERSION of the Android SDK from the dropdown menu.
  2. Click the icon in the DOWNLOAD column.
  3. On your computer, unzip the SDK .zip file.

Add the SDK dependencies

  1. From within Android Studio, open your app.
  2. Create a new directory in your app directory named libs
  3. Copy and Paste jwplayer-core-x.x.x.aar into the libs folder
  4. Repeat step 3 for jwplayer-common-x.x.x.aar

Complete app and project configurations

  1. In the app build.gradle file:

    • Add the JW Player and Android dependencies. When prompted by Android Studio, update the dependency versions.

    • Configure compileOptions to support Java 8 language support.
ext.exoplayerVersion = '2.14.0'

dependencies {
    ...
    // JW Player SDK classes
    implementation fileTree(dir: 'libs', include: 'jwplayer-core-x.x.x.aar')
    implementation fileTree(dir: 'libs', include: 'jwplayer-common:x-x.x.x.aar')

    // ExoPlayer dependencies
    implementation "com.google.android.exoplayer:exoplayer-core:$exoplayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-dash:$exoplayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-hls:$exoplayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-smoothstreaming:$exoplayerVersion"
    implementation "com.google.android.exoplayer:exoplayer-ui:$exoplayerVersion"

    // JW Player Native UI dependencies
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
    implementation 'com.android.volley:volley:1.2.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
}
android {
    defaultConfig {
        ...
        minSdkVersion 21
        multiDexEnabled true
    }
    ...
    compileOptions {
        sourceCompatibility = '1.8'
        targetCompatibility = '1.8'
    }
}
  1. In the gradle.properties file, set android.useAndroidX and android.enableJetifier to true. These plugin files enable you to use androidx-namespaced libraries in your project.

    If you are using a current version of Android Studio, the gradle.properties file should already contain these settings.
# Project-wide Gradle settings.

android.useAndroidX=true
android.enableJetifier=true
  1. Sync Gradle.

You have imported the JW Player SDK for Android into your project. You can now configure ProGuard and configure the manifest.



Did this page help you?