Add the Android SDK (Android v3)

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


To add a player to your app, you must import the JWP 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• JWP 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 JWP license, please log a support ticket for assistance.


šŸ“˜

You can also refer to our JWP 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 JWP 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 JWP Maven repository: https://mvn.jwplayer.com/content/repositories/releases/.

    allprojects {
        repositories {
    		    ...
            maven {
                url 'https://mvn.jwplayer.com/content/repositories/releases/'
            }
        }
    }

  3. In the app build.gradle file, add the JWP 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'
    }

  4. 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'
        }
    }

  5. 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
  6. Sync Gradle.


You have imported the JWP 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. In your dashboard, select the property from the Property menu at the top of the left navigation.
  2. At the bottom of the left navigation, click Property settings. The property settings page appears.
  3. Open the player setup files:
    • Admin: Under Network & setup files, click Player setup files.
    • Manager: Click the Player Setup Files tab.
  4. Under Android SDK, click Download v4.xx.x. This button downloads the current v4 SDK. The page does not offer earlier versions.
  5. On your computer, unzip the SDK .zip file.
šŸ“˜

Only Admin and Manager users can see the player setup files. Editor, Read Only and Operations users cannot see them. Each property has a unique set of license keys.


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 JWP 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'
    }

  2. 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'
        }
    }

  3. 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
  4. Sync Gradle.


You have imported the JWP 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?
© 2007- Longtail Ad Solutions, Inc.