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 #1181

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 of the viewpager's recycler view and added it as a LifecyclerObserver with the parent Fragment. There are few crashes recorded on the Firebase crashlytics dashboard. Caused by android.net.ConnectivityManager$TooManyRequestsException

Environment details

Android Version: Android 8 to Android 15

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: c721ed84130836e878d543624f468fd5

Session: 672F8E2A02B0000129A4656520CF8AF3_DNE_8_v2

Date: Sun Nov 10 2024 21:22:01 GMT+0530 (India Standard Time)

Fatal Exception: android.view.InflateException: Binary XML file line #74 in layout/youtube_player com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView: Error inflating class

Caused by android.view.InflateException: Binary XML file line #74 in layout/youtube_player: com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView Error inflating class

Caused by java.lang.reflect.InvocationTargetException: at java.lang.reflect.Constructor.newInstance0(Constructor.java) at java.lang.reflect.Constructor.newInstance(Constructor.java:343) at android.view.LayoutInflater.createView(LayoutInflater.java:858) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.inflate(LayoutInflater.java:686) at android.view.LayoutInflater.inflate(LayoutInflater.java:538) at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:126) at androidx.databinding.ViewDataBinding.inflateInternal(ViewDataBinding.java:1409) at com.leanagri.leannutri.databinding.ItemImagesBannerBinding.inflate(ItemImagesBannerBinding.java:105) at com.leanagri.leannutri.databinding.ItemImagesBannerBinding.inflate(ItemImagesBannerBinding.java:91) at com.leanagri.leannutri.v3_1.ui.ecommerce.details.adapters.ImageBannerAdapter.onCreateViewHolder(ImageBannerAdapter.kt:46) at com.leanagri.leannutri.v3_1.ui.ecommerce.details.adapters.ImageBannerAdapter.onCreateViewHolder(ImageBannerAdapter.kt:25) at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7788) at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6873) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6757) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6753) at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2362) at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1662) at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1622) at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:687) at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4645) at androidx.recyclerview.widget.RecyclerView.onMeasure(RecyclerView.java:4022) at android.view.View.measure(View.java:27129) at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:811) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:632) at androidx.constraintlayout.core.widgets.analyzer.Direct.horizontalSolvingPass(Direct.java:323) at androidx.constraintlayout.core.widgets.analyzer.Direct.solveHorizontalMatchConstraint(Direct.java:709) at androidx.constraintlayout.core.widgets.analyzer.Direct.horizontalSolvingPass(Direct.java:374) at androidx.constraintlayout.core.widgets.analyzer.Direct.solvingPass(Direct.java:144) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.layout(ConstraintWidgetContainer.java:693) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solveLinearSystem(BasicMeasure.java:160) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:291) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:120) at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem(ConstraintLayout.java:1594) at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1708) at android.view.View.measure(View.java:27129) at androidx.core.widget.NestedScrollView.measureChildWithMargins(NestedScrollView.java:1941) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at androidx.core.widget.NestedScrollView.onMeasure(NestedScrollView.java:650) at android.view.View.measure(View.java:27129) at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:811) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:632) at androidx.constraintlayout.core.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:452) at androidx.constraintlayout.core.widgets.analyzer.Direct.solveVerticalMatchConstraint(Direct.java:750) at androidx.constraintlayout.core.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:503) at androidx.constraintlayout.core.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:542) at androidx.constraintlayout.core.widgets.analyzer.Direct.solvingPass(Direct.java:224) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.layout(ConstraintWidgetContainer.java:693) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solveLinearSystem(BasicMeasure.java:160) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:291) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:120) at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem(ConstraintLayout.java:1594) at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1708) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at android.view.View.measure(View.java:27129) at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:811) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:632) at androidx.constraintlayout.core.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:452) at androidx.constraintlayout.core.widgets.analyzer.Direct.solveVerticalMatchConstraint(Direct.java:750) at androidx.constraintlayout.core.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:503) at androidx.constraintlayout.core.widgets.analyzer.Direct.solvingPass(Direct.java:224) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.layout(ConstraintWidgetContainer.java:693) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solveLinearSystem(BasicMeasure.java:160) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:291) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:120) at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem(ConstraintLayout.java:1594) at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1708) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552) at android.widget.LinearLayout.measureVertical(LinearLayout.java:842) at android.widget.LinearLayout.onMeasure(LinearLayout.java:721) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552) at android.widget.LinearLayout.measureVertical(LinearLayout.java:842) at android.widget.LinearLayout.onMeasure(LinearLayout.java:721) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:1278) at android.view.View.measure(View.java:27129) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:4541) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:3233) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3538) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2924) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10513) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1108) at android.view.Choreographer.doCallbacks(Choreographer.java:866) at android.view.Choreographer.doFrame(Choreographer.java:797) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1092) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8751) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Caused by android.net.ConnectivityManager$TooManyRequestsException: at android.net.ConnectivityManager.convertServiceException(ConnectivityManager.java:4460) at android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:4736) at android.net.ConnectivityManager.registerDefaultNetworkCallbackForUid(ConnectivityManager.java:5381) at android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:5348) at android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:5322) at com.pierfrancescosoffritti.androidyoutubeplayer.core.player.utils.NetworkObserver.doObserveNetwork(NetworkObserver.kt:76) at com.pierfrancescosoffritti.androidyoutubeplayer.core.player.utils.NetworkObserver.observeNetwork(NetworkObserver.kt:31) at com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.LegacyYouTubePlayerView.initialize(LegacyYouTubePlayerView.kt:104) at com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView.(YouTubePlayerView.kt:89) at com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView.(YouTubePlayerView.kt:33) at java.lang.reflect.Constructor.newInstance0(Constructor.java) at java.lang.reflect.Constructor.newInstance(Constructor.java:343) at android.view.LayoutInflater.createView(LayoutInflater.java:858) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1010) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088) at android.view.LayoutInflater.inflate(LayoutInflater.java:686) at android.view.LayoutInflater.inflate(LayoutInflater.java:538) at androidx.databinding.DataBindingUtil.inflate(DataBindingUtil.java:126) at androidx.databinding.ViewDataBinding.inflateInternal(ViewDataBinding.java:1409) at com.leanagri.leannutri.databinding.ItemImagesBannerBinding.inflate(ItemImagesBannerBinding.java:105) at com.leanagri.leannutri.databinding.ItemImagesBannerBinding.inflate(ItemImagesBannerBinding.java:91) at com.leanagri.leannutri.v3_1.ui.ecommerce.details.adapters.ImageBannerAdapter.onCreateViewHolder(ImageBannerAdapter.kt:46) at com.leanagri.leannutri.v3_1.ui.ecommerce.details.adapters.ImageBannerAdapter.onCreateViewHolder(ImageBannerAdapter.kt:25) at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7788) at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6873) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6757) at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6753) at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2362) at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1662) at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1622) at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:687) at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4645) at androidx.recyclerview.widget.RecyclerView.onMeasure(RecyclerView.java:4022) at android.view.View.measure(View.java:27129) at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:811) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:632) at androidx.constraintlayout.core.widgets.analyzer.Direct.horizontalSolvingPass(Direct.java:323) at androidx.constraintlayout.core.widgets.analyzer.Direct.solveHorizontalMatchConstraint(Direct.java:709) at androidx.constraintlayout.core.widgets.analyzer.Direct.horizontalSolvingPass(Direct.java:374) at androidx.constraintlayout.core.widgets.analyzer.Direct.solvingPass(Direct.java:144) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.layout(ConstraintWidgetContainer.java:693) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solveLinearSystem(BasicMeasure.java:160) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:291) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:120) at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem(ConstraintLayout.java:1594) at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1708) at android.view.View.measure(View.java:27129) at androidx.core.widget.NestedScrollView.measureChildWithMargins(NestedScrollView.java:1941) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at androidx.core.widget.NestedScrollView.onMeasure(NestedScrollView.java:650) at android.view.View.measure(View.java:27129) at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:811) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:632) at androidx.constraintlayout.core.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:452) at androidx.constraintlayout.core.widgets.analyzer.Direct.solveVerticalMatchConstraint(Direct.java:750) at androidx.constraintlayout.core.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:503) at androidx.constraintlayout.core.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:542) at androidx.constraintlayout.core.widgets.analyzer.Direct.solvingPass(Direct.java:224) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.layout(ConstraintWidgetContainer.java:693) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solveLinearSystem(BasicMeasure.java:160) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:291) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:120) at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem(ConstraintLayout.java:1594) at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1708) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at android.view.View.measure(View.java:27129) at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:811) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:632) at androidx.constraintlayout.core.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:452) at androidx.constraintlayout.core.widgets.analyzer.Direct.solveVerticalMatchConstraint(Direct.java:750) at androidx.constraintlayout.core.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:503) at androidx.constraintlayout.core.widgets.analyzer.Direct.solvingPass(Direct.java:224) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.layout(ConstraintWidgetContainer.java:693) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solveLinearSystem(BasicMeasure.java:160) at androidx.constraintlayout.core.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:291) at androidx.constraintlayout.core.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:120) at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem(ConstraintLayout.java:1594) at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1708) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552) at android.widget.LinearLayout.measureVertical(LinearLayout.java:842) at android.widget.LinearLayout.onMeasure(LinearLayout.java:721) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552) at android.widget.LinearLayout.measureVertical(LinearLayout.java:842) at android.widget.LinearLayout.onMeasure(LinearLayout.java:721) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:1278) at android.view.View.measure(View.java:27129) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:4541) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:3233) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3538) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2924) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10513) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1108) at android.view.Choreographer.doCallbacks(Choreographer.java:866) at android.view.Choreographer.doFrame(Choreographer.java:797) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1092) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8751) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

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/1024

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 )