Migrate from SDK v3 to SDK v4

Explore JW Player's new Android SDK v4.


📘

Try It Now!

We're eager for you to experience the new Android SDK v4. To get started, read Android Migration Guide: SDK 4.x now!


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 JW Player 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;
   player.setup(this.playerConfig);
});

You can also initialize your player synchronously.

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

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:

com.google.ads.interactivemedia.v3:interactivemedia:3.20.0
com.google.android.gms:play-services-cast-framework:19.0.0



Did this page help you?