Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on android setup track player #1678

Closed
Surinder1922 opened this issue Aug 26, 2022 · 10 comments
Closed

Crash on android setup track player #1678

Surinder1922 opened this issue Aug 26, 2022 · 10 comments
Labels

Comments

@Surinder1922
Copy link

Describe the Bug
App crashed on playing audio files after react-native-video settings/configure to start android expo player to support .m3u8 file . .But now audio is not getting play . l

Steps To Reproduce
Simply play any of the file .mp3 or .m3u8 file with basic syntax provided in documentation.

Code To Reproduce
React.useEffect(() => {
TrackPlayer.destroy()
initPlayer()
}, [initPlayer])

const initPlayer = React.useCallback(async () => {
await TrackPlayer.add(track)
await TrackPlayer.setupPlayer({
iosCategory: IOSCategory.Playback,
})
await TrackPlayer.updateOptions({
stopWithApp: true,
// Media controls capabilities
capabilities: [
Capability.Play,
Capability.Pause,
Capability.SeekTo,
Capability.JumpBackward,
Capability.JumpForward,
// Capability.SkipToNext,
// Capability.SkipToPrevious,
],
// Capabilities that will show up when the notification is in the compact form on Android
compactCapabilities: [Capability.Play, Capability.Pause],
})
await TrackPlayer.setRepeatMode(RepeatMode.Queue)
await TrackPlayer.play()
}, [track])

**Environment Info:**System:
OS: macOS 12.4
CPU: (8) arm64 Apple M1
Memory: 221.48 MB / 8.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.5.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.12.1 - /opt/homebrew/bin/npm
Watchman: 2022.07.04.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
Android NDK: 21.4.7075529
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8609683
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
Java: 11.0.15 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.67.4 => 0.67.4

"react-native-track-player": "^2.1.3",
"react-native-video": "^5.2.0",

Real device? Or simulator?

Real device

What OS are you running?

Android

Have you investigated the underlying JS or Swift/Android code causing this bug?

Yes , i have debug it on Android studio and collect logs/errors from there , Please find :

2022-08-26 13:21:28.469 8916-8916/dog.fa.so.app.dev E/AndroidRuntime: FATAL EXCEPTION: main
Process: dog.fa.so.app.dev, PID: 8916
java.lang.NoSuchMethodError: No virtual method setAudioAttributes(Lcom/google/android/exoplayer2/audio/AudioAttributes;)V in class Lcom/google/android/exoplayer2/SimpleExoPlayer; or its super classes (declaration of 'com.google.android.exoplayer2.SimpleExoPlayer' appears in /data/app/dog.fa.so.app.dev-FPK8SmieQn-ps2B_BZ5VBg==/base.apk)
at com.guichaguri.trackplayer.service.MusicManager.createLocalPlayback(MusicManager.java:135)
at com.guichaguri.trackplayer.service.MusicBinder.getPlayback(MusicBinder.java:34)
at com.guichaguri.trackplayer.module.MusicModule.lambda$add$2$MusicModule(MusicModule.java:217)
at com.guichaguri.trackplayer.module.-$$Lambda$MusicModule$J1NWez-KlR3vIDysIhw_Wj11q64.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7592)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

@stereodenis
Copy link

I got this
java.lang.NoSuchMethodError: No direct method (Lcom/google/android/exoplayer2/trackselection/ExoTrackSelection$Factory;)V in class Lcom/google/android/exoplayer2/trackselection/DefaultTrackSelector; or its super classes (declaration of 'com.google.android.exoplayer2.trackselection.DefaultTrackSelector'

@Surinder1922
Copy link
Author

@stereodenis , Are you also using both react-native-video and react-native-track-player packages together ?

@stereodenis
Copy link

@Surinder1922 yep. Trying to make them work together)

@jspizziri
Copy link
Collaborator

Please upgrade to 3.1 and read through the other issues on how to make react-native-video play nice.

@Surinder1922
Copy link
Author

@jspizziri I have upgraded the package to 3.1 and also tried @nightly but i got this error on app launch :-

ERROR Error: Exception in HostObject::get for prop 'UIManager': java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/exoplayer2/Player$EventListener;, js engine: hermes

please help and if it is possible share any reference of the solution to get react-native-video play nicely with this package.

Many thanks .

@Surinder1922
Copy link
Author

@Surinder1922 yep. Trying to make them work together)

Do you get any solution for the same , if yes please help me thanks @stereodenis

@jspizziri
Copy link
Collaborator

@Surinder1922 it sounds like something is wrong with your local installation, and I'm not sure what that could be. Please look at the migration guide and the example project for guidance.

https://react-native-track-player.js.org/docs/v3-migration

Make sure you're using a react-native-video version that uses a compatible version of ExoPlayer as RNTP.

@Surinder1922
Copy link
Author

@jspizziri thank you , May i know which ExpoPlayer is being used in RNTP in 3.1 . Today i have tried react-native-video@6.0 which is using com.google.android.exoplayer:exoplayer:2.17.1 . I got this error while playing media in RNTP

java.lang.NoSuchMethodError: No direct method <init>(Lcom/google/android/exoplayer2/trackselection/ExoTrackSelection$Factory;)V in class Lcom/google/android/exoplayer2/trackselection/DefaultTrackSelector; or its super classes (declaration of 'com.google.android.exoplayer2.trackselection.DefaultTrackSelector' appears in /data/app/dog.fa.so.app.dev-THviPpSc-HJ_VHqo6MRbhg==/base.apk!classes21.dex) at com.brentvatne.exoplayer.ReactExoplayerView.initializePlayerCore(ReactExoplayerView.java:551) at com.brentvatne.exoplayer.ReactExoplayerView.access$1100(ReactExoplayerView.java:113) at com.brentvatne.exoplayer.ReactExoplayerView$6.run(ReactExoplayerView.java:501) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7592) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

@jspizziri
Copy link
Collaborator

@Surinder1922 v2.18.1

@Surinder1922
Copy link
Author

@jspizziri Okay thank you , I will explore the react-native-video then .

If you have any suggestion/solution for this problem please provide i mean if there is any RNTP version available with v2.17.1 or related solution .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants