1

I'm using the Youtube API to play Youtube videos in my Android app. It works fine on newer phones, but when I try to run on a device running Gingerbread, I get the error:

Unable to resolve superclass of Lcom/google/android/youtube/player/YouTubePlayerFragment; (21)
Link of class 'Lcom/google/android/youtube/player/YouTubePlayerFragment;' failed
VFY: unable to resolve static method 9606: Lcom/google/android/youtube/player/YouTubePlayerFragment;.newInstance ()Lcom/google/android/youtube/player/YouTubePlayerFragment;
thread exiting with uncaught exception (group=0x40015578)
FATAL EXCEPTION: main java.lang.NoClassDefFoundError: com.google.android.youtube.player.YouTubePlayerFragment

I've read many other SO questions regarding the NoClassDefFoundError, but I can't seem to resolve this issue. These are the things I've done:

  • Cleaned the project
  • Added YouTubeAdnroidPlayerApi.jar to my libs folder
  • Under "Order and Export" in the Java Build Path, I made sure YouTubePlayerApi.jar was checked.
  • The YouTubeAndroidPlayerApi.jar is listed under my libraries in my Java Build Path
  • Ensured that I have a version of the YouTube app on the device that is compatible with the YouTube API (the phone has YouTube Version 5.3.24)

Does anyone know how to solve this problem?

scientiffic
  • 9,045
  • 18
  • 76
  • 149

2 Answers2

1

I don't believe fragments are supported pre-honeycomb (without appropriate compatibility libraries that is).

Try using com.google.android.youtube.player.YouTubePlayerSupportFragment instead.

See here for more information: https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubePlayerSupportFragment

CzarMatt
  • 1,773
  • 18
  • 22
  • do you know of any examples of how to use this? I'm new to android and haven't used fragments before. – scientiffic Dec 12 '13 at 22:53
  • 2
    This may help you out: http://stackoverflow.com/questions/20302110/struggling-with-youtube-player-support-fragment/20363160#20363160 – CzarMatt Dec 13 '13 at 00:27
0
please use the older API 1.0 I also have the same issue with 1.2.
Prateek Yadav
  • 932
  • 6
  • 8