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)• No SDK download is required.
• Core and optional modules must be added to your app.
• ProGuard automatically applied. ProGuard protects the SDK classes.
• An existing app is required.
Local• JW Player SDK for Android must be downloaded and unzipped.
• Core and optional modules must be imported.
• ProGuard must be configured. ProGuard protects the SDK classes.
• 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.


📘

DEMO APP

You can also refer to our JW Player SDK for Android Open Source Demo. The open-source demo is a basic demonstration app that allows you to experiment with the SDK. All modules are included. ProGuard automatically applied.

  1. Open Android Studio, click Check out project from Version Control, and select Git. The Clone Repository popup window appears.
  2. Fill out the Clone Repository popup window:
       • Enter https://github.com/jwplayer/jwplayer-sdk-android-demo for the URL.
       • Enter a Directory into which the repository should be cloned.
  3. Click Clone.
  4. Follow the Android Studio prompts to open the demo app.
  5. In the AndroidManifest.xml file assign your JW Player license key to android:value.


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.
dependencies {
    ...
    implementation 'com.longtailvideo.jwplayer:jwplayer-core:x.x.x'
    implementation 'com.longtailvideo.jwplayer:jwplayer-common:x.x.x'
    
    // Only required if using Chromecast feature
    implementation 'com.longtailvideo.jwplayer:jwplayer-chromecast:x.x.x'

    // Only required if using IMA features
    implementation 'com.longtailvideo.jwplayer:jwplayer-ima:x.x.x'
    
    // Only required if using FreeWheel
    implementation 'com.longtailvideo.jwplayer:jwplayer-freewheel:x.x.x'
}

  1. Also in the app build.gradle file, configure compileOptions to support Java 8 language support and set multiDexEnabled true if your project is configured to minSdkVersion 21. If your minSdkVersion is less than 21, follow Google's instructions to add Multidex support prior to Android 5.0.
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 the manifest file. If necessary, you can also configure ProGuard.



Local

Download the Android SDK .zip file

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

    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.

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

Add the SDK dependencies

  1. From within Android Studio, open your app.
  2. Click File > New > New Module... > Import .JAR / .AAR Package.
  3. Click Next.
  4. Select jwplayer-core-x.x.x.aar from your computer.
  5. Click Finish.
  6. Repeat the previous steps and add jwplayer-common-x.x.x.aar.
  7. Click File > Project Structure... > Dependencies. Under Modules, be sure that your app is selected.
  8. Click the plus sign in the main panel.
  9. Select Module dependency.
  10. Select jwplayer-core-x.x.x and jwplayer-common-x.x.x.
  11. Click OK.
  12. Click Apply.
  13. Click OK.

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.
dependencies {
    ...
    implementation 'com.longtailvideo.jwplayer:jwplayer-core:x.x.x'
    implementation 'com.longtailvideo.jwplayer:jwplayer-common:x.x.x'
    implementation 'com.google.android.exoplayer:exoplayer-core:2.10.6'
    implementation 'com.google.android.exoplayer:exoplayer-dash:2.10.6'
    implementation 'com.google.android.exoplayer:exoplayer-hls:2.10.6'
    implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.10.6'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.10.6'
    implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
}

  1. Also in the app build.gradle file, configure compileOptions to support Java 8 language support and set multiDexEnabled true if your project is configured to minSdkVersion 21. If your minSdkVersion is less than 21, follow Google's instructions to add Multidex support prior to Android 5.0.
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 the manifest file. If necessary, you can also configure ProGuard.



Did this page help you?