PierfrancescoSoffritti / android-youtube-player

YouTube Player library for Android and Chromecast, stable and customizable.
https://pierfrancescosoffritti.github.io/android-youtube-player/
MIT License
3.44k stars 765 forks source link

App crash #1182

Open burhanz-bharatagri opened 5 days ago

burhanz-bharatagri commented 5 days ago

Bug Report

Description of the Bug

I have added the YouTube player in the recycler view and added it as a LifecyclerObserver with the parent Fragment. There are few crashes recorded on the Firebase crashlytics dashboard. Fatal Exception: java.lang.IllegalArgumentException NetworkCallback was not registered

Environment details

Android Version: Android 10 to Android 14

Tested devices:

Youtube Player Library Version: 12.1.1

Sharing the stack trace here

Crashlytics - Stack trace

Platform: android

Version: 3.3.91.3 (300913)

Issue: 173d9a40b3313ffaf08e5d80386b939f

Session: 6730893D03DA000163F44FD69EE1448C_DNE_8_v2

Date: Sun Nov 10 2024 16:36:45 GMT+0530 (India Standard Time)

Fatal Exception: java.lang.IllegalArgumentException: NetworkCallback was not registered at com.android.internal.util.Preconditions.checkArgument(Preconditions.java:47) at android.net.ConnectivityManager.unregisterNetworkCallback(ConnectivityManager.java:3416) at com.pierfrancescosoffritti.androidyoutubeplayer.core.player.utils.NetworkObserver.destroy(NetworkObserver.kt:43) at com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.LegacyYouTubePlayerView.release(LegacyYouTubePlayerView.kt:179) at com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView.release(YouTubePlayerView.kt:208) at com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView.onStateChanged(YouTubePlayerView.kt:200) at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.jvm.kt:320) at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.jvm.kt:272) at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.jvm.kt:289) at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.jvm.kt:142) at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.jvm.kt:124) at androidx.fragment.app.Fragment.performDestroy(Fragment.java:3372) at androidx.fragment.app.FragmentStateManager.destroy(FragmentStateManager.java:812) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:346) at androidx.fragment.app.SpecialEffectsController$FragmentStateManagerOperation.complete(SpecialEffectsController.kt:664) at androidx.fragment.app.SpecialEffectsController$Operation.completeSpecialEffect(SpecialEffectsController.kt:587) at androidx.fragment.app.DefaultSpecialEffectsController$SpecialEffectsInfo.completeSpecialEffect(DefaultSpecialEffectsController.kt:774) at androidx.fragment.app.DefaultSpecialEffectsController$startAnimations$3.onAnimationEnd$lambda$0(DefaultSpecialEffectsController.kt:273) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:192) at android.app.ActivityThread.main(ActivityThread.java:6759) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:875)

OkHttp Dispatcher: at java.lang.Object.wait(Object.java) at java.lang.Thread.parkFor$(Thread.java:2159) at sun.misc.Unsafe.park(Unsafe.java:358) at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230) at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:461) at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:362) at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:937) at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1086) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1147) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

burhanz-bharatagri commented 3 days ago

Similar to this I am facing. Let me know the solution. https://github.com/PierfrancescoSoffritti/android-youtube-player/issues/1049

XML file

<com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView android:id="@+id/youtube_player_view" android:layout_width="match_parent" android:layout_height="match_parent" />

Player Initialization

val iFramePlayerOptions = IFramePlayerOptions.Builder() .controls(1) .fullscreen(1) // enable full screen button .build() binding.youtubePlayerView.enableAutomaticInitialization =false binding.youtubePlayerView.initialize( youTubePlayerListener = youTubePlayerListener, playerOptions = iFramePlayerOptions, handleNetworkEvents = true )