'react-native-track-player crashing due to exo player version conflict in track-player and react-native-video

So I am using react-native-video and react-native-track-player parallelly, Normally both are working fine, but to use some extra functionalities of video player like buffering I have to use Exo player , but using exo player manually is making react-native-track player crash well i was trying to get an answer and find that it was happening due to conflict in exo player versions used by both libs. can anyone help

Thanks



Solution 1:[1]

I know the question is a long time ago, but it might help someone, I had the same problem, solved using the 'patch-package'

https://gist.github.com/Fairbrook/53127f8a05c020836a64f6c19b71f889#file-react-native-track-player-2-1-2-patch

to use is simple
1 - npm i patch-package
2 - Create folder in the project root with name 'patches'
3 - Create a file named 'react-native-track-player+2.1.2.patch'
4 - Copy the code from the link and paste it in the file
5 - npm install

This should solve it, solve it for me

Solution 2:[2]

Problem background

Both react-native-track-player and react-native-video are built on top of the Exoplayer (the application level media player for android).

In the current versions of react-native-track-player and the react-native-video the following exoplayer versions are used:

  • react-native-track-player (2.1.3): node_modules\react-native-track-player\android\build.gradle

     dependencies {
         ...   
         def exoPlayerVersion = safeExtGet("exoPlayerVersion", '2.11.4')
         ...
     }
    
  • react-native-video (5.2.0): node_modules\react-native-video\android-exoplayer\build.gradle

     dependencies {
         ...
         implementation('com.google.android.exoplayer:exoplayer:2.13.2') {
             exclude group: 'com.android.support'
         }
         ...
         implementation('com.google.android.exoplayer:extension-okhttp:2.13.2') 
         {
             exclude group: 'com.squareup.okhttp3', module: 'okhttp'
         }
         ...
     }
    

As you can see both require different versions of the exoplayer which causes the problem (application crash).

Solution

The available solution is to make sure both packages use the same version of exoplayer. We can achieve this by downgrading one of the packages until it matches the exoplayer version of the other. Since current version react-native-track-player uses the older version of exoplayer (2.11.4) we have no option but to downgrade react-native-video down to the version which use exoplayer 2.11.4 which is the version 5.1.1.

Therefore the problem will be solved if you downgrade the react-native-video down to 5.1.1.

npm i [email protected]

Note: This may cause some minor issues in react-native-video. (ex: textTracks property of Video class might not work)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Abotturi148
Solution 2