React Native: How to fix TypeError: null is not an object (evaluating 'TrackPlayer.STATE_NONE')?

7.6k Views Asked by At

I entered the following commands in the powershell in the folder containing my alarm app:

npm install react-native-track-player 
react-native link react-native-track-player 

react-native link seemed to have done nothing, so I manually linked the module following the steps given from the module info.

However, when I include the following line in one of my .js components:

import TrackPlayer from 'react-native-track-player'

I get the following error on my Android device:

TypeError: null is not an object (evaluating 'TrackPlayer.STATE_NONE')

How can I fix this?

Versions:

  • react-native-cli: 2.0.1
  • react-native: 0.61.5

Here are some screenshots of the stack trace:

  1. Pt 1
  2. Pt 2
  3. Pt 3
1

There are 1 best solutions below

0
On

RN 0.61.5 has autolinking so you don't need to link it manually.

First, try to unlink

react-native unlink react-native-track-player 

If you are developing for ios

cd ios && pod install

Then try to run your project again