React-native-track-player: On Android app crashed after installing

Created on 20 Aug 2019  路  4Comments  路  Source: react-native-kit/react-native-track-player

Configuration

info
React Native Environment Info:
System:
OS: macOS 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
Memory: 613.13 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.2 - /usr/local/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
Android SDK:
API Levels: 22, 23, 24, 25, 26, 27, 28, 29
Build Tools: 23.0.1, 25.0.3, 26.0.2, 27.0.3, 28.0.3
System Images: android-18 | Google APIs ARM EABI v7a, android-21 | Google APIs ARM EABI v7a, android-21 | Google APIs Intel x86 Atom, android-21 | Google APIs Intel x86 Atom_64, android-22 | Google APIs ARM EABI v7a, android-22 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom_64, android-23 | Google APIs ARM EABI v7a, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google APIs ARM EABI v7a, android-24 | Google APIs Intel x86 Atom, android-24 | Google APIs Intel x86 Atom_64, android-25 | Google APIs ARM 64 v8a, android-25 | Google APIs ARM EABI v7a, android-25 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom_64, android-25 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-29 | Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
npmPackages:
react: 16.6.1 => 16.6.1
react-native: 0.59.3 => 0.59.3
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7

Issue

i Just installed the the version 1.1.8 from yarn linked on android and ios it runs fine on IOS but when run on the app got crashed.

Android

Most helpful comment

This issue happens when you pass a null/undefined value to the capabilities option. Figure out what is null/undefined, remove it and it should stop crashing.

All 4 comments

Same issue here.

I see this error in logs when i try to run:

08-20 22:01:40.713 11360 11360 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
08-20 22:01:40.713 11360 11360 E AndroidRuntime:    at com.guichaguri.trackplayer.service.metadata.MetadataManager.updateOptions(MetadataManager.java:112)
08-20 22:01:40.713 11360 11360 E AndroidRuntime:    at com.guichaguri.trackplayer.service.MusicBinder.updateOptions(MusicBinder.java:45)
08-20 22:01:40.713 11360 11360 E AndroidRuntime:    at com.guichaguri.trackplayer.module.MusicModule.onServiceConnected(MusicModule.java:74)
08-20 22:01:40.713 11360 11360 E AndroidRuntime:    at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1516)
08-20 22:01:40.713 11360 11360 E AndroidRuntime:    at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1544)

Btw i use the latest version, but also the 1.1.8 has the same problem :(

Same here.

> AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
> AndroidRuntime:   at com.guichaguri.trackplayer.service.metadata.MetadataManager.updateOptions(MetadataManager.java:112)
> AndroidRuntime:   at com.guichaguri.trackplayer.service.MusicBinder.updateOptions(MusicBinder.java:45)
> AndroidRuntime:   at com.guichaguri.trackplayer.module.MusicModule.onServiceConnected(MusicModule.java:74)
> AndroidRuntime:   at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1652)
> AndroidRuntime:   at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1681)
> AndroidRuntime:   at android.os.Handler.handleCallback(Handler.java:790)
> AndroidRuntime:   at android.os.Handler.dispatchMessage(Handler.java:99)
> AndroidRuntime:   at android.os.Looper.loop(Looper.java:164)
> AndroidRuntime:   at android.app.ActivityThread.main(ActivityThread.java:6543)
> AndroidRuntime:   at java.lang.reflect.Method.invoke(Native Method)
> AndroidRuntime:   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
> AndroidRuntime:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)

Hi! I had the same issue but @dcvz's comment (https://github.com/react-native-kit/react-native-track-player/issues/668#issuecomment-511806298) pointed me in the right direction:

Was importing constants like this:

import TrackPlayer, {
  CAPABILITY_PLAY,
  CAPABILITY_PAUSE
} from "react-native-track-player";

Before using in TrackPlayer.updateOptions()
Had to replace it by:

import TrackPlayer, { Capability } from "react-native-track-player";

This fixed the crash!

This issue happens when you pass a null/undefined value to the capabilities option. Figure out what is null/undefined, remove it and it should stop crashing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RiccardoNL picture RiccardoNL  路  3Comments

toooldmohammad picture toooldmohammad  路  3Comments

fabiocosta88 picture fabiocosta88  路  3Comments

mnlbox picture mnlbox  路  4Comments

krunalbad picture krunalbad  路  3Comments