Android Studio layout preview not showing when adding YoutubePlayer Component, Exception in layout

167 Views Asked by At

I'm having an issue with a YoutubePlayerView, thats causing my entire layout to be invisible. When I delete it or remove it from the design, all of the remaining becomes visible. It is showing a message warning,

The following classes could not be instantiated:
- com.google.android.youtube.player.YouTubePlayerView (Open Class, Show Exception, Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  If this is an unexpected error you can also try to build the project, then manually refresh the layout.  Exception Details java.lang.IllegalStateException: A YouTubePlayerView can only be created with an Activity which extends YouTubeBaseActivity as its context.   at com.google.android.youtube.player.YouTubePlayerView.<init>  at com.google.android.youtube.player.YouTubePlayerView.<init>  at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(NativeConstructorAccessorImpl.java:-2)   at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)   at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)   at java.lang.reflect.Constructor.newInstance(Constructor.java:490)   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)   at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1127)   at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)   at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)   at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)   at android.view.LayoutInflater.inflate(LayoutInflater.java:686)   at android.view.LayoutInflater.inflate(LayoutInflater.java:505) Copy stack to clipboard

Things to consider:

  • When the app is running the Youtube Player is working fine

What i've tried: (DIDN'T WORKED)

  • Invalidating cache and restarting IDE
  • Reinstalling Android Studio
  • Creating a new fragment with only a YoutubePlayerView Component

Android Studio Capture

I'll be glad if someone could help, been stuck with this for a week

0

There are 0 best solutions below