Migrate from SDK v3 to SDK v4 (Android)

Explore JW Player's new Android SDK v4.

In the new Android SDK v4, we've made several changes to improve both the developer and viewer experiences.

Decoupled JWPlayerView

The JWPlayerView has been decoupled from the JWP API. This decoupling enables your layouts to inflate quickly and provide a responsive user experience on screens that have a JWPlayerView.

This decoupling also gives you the flexibility to instantiate the SDK’s major components when it is convenient for your app -- not just when you need to display the layout containing JWPlayerView. For example, instantiating the player API and the player’s internal components requires only two steps:

  1. Get a reference to your JWPlayerView.
  2. Call getPlayerAsync().
    JWPlayerView playerView = findViewById(R.id.jw_player_view);
    playerView.getPlayerAsync(this, getLifecycle(), (JWPlayer player) -> {
       // JWPlayer is the API instance for this JWPlayerView
       this.player = player;

You can also initialize your player synchronously.

JWPlayerView playerView = findViewById(R.id.jw_player_view);
JWPlayer player = playerView.getPlayer();
this.player = player;

Updated Java Package Root

We have updated our Java package root to be com.jwplayer. If you do not see a class, you may need to update your imports. Delete the import line that is highlighted in red by Android Studio. Android Studio will re-import it correctly.

Fully Native Controls

The Android 4.x SDK uses fully native controls. As a developer, this simplifies control customization. We use a MVVM pattern for our UI controls which enables ViewModels to be available for all of the standard controls that you can reuse. This means you only need to create your own views and bind them to our ViewModels.

AAR Distribution

Since the SDK is distributed as AAR files transitive dependencies will not automatically be added to your project. If you would like to use the IMA or ChromeCast modules you will need to add these dependencies to your application’s build.gradle:


Next Step

Before begin migrating to v4, review the Android Migration Reference to see a detailed listing of the differences between the Android SDK v3 and Android SDK v4.