AndroidDev
AndroidDev

Reputation: 21237

YouTubePlayerSupportFragment cannot be resolved

I'm unable to get the YouTubePlayerSupportFragment correctly compiled into my project. I've reviewed this post and this post and have implemented the suggestions there, but still no luck.

Here is what I have tried so far: I have the YouTube API saved in my libs folder. The dependencies section of my gradle file looks like this. You can see that I've tried to include the library using gradle. Whether I comment this line out or not (and sync, of course), I still have the same result.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'

    compile 'com.google.dagger:dagger:2.0.1'
    apt 'com.google.dagger:dagger-compiler:2.0.1'
    provided 'org.glassfish:javax.annotation:10.0-b28'

    compile 'commons-codec:commons-codec:1.10'
    compile 'org.apache.commons:commons-io:1.3.2'

    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'

    compile 'joda-time:joda-time:2.8.2'

    compile 'com.google.android.gms:play-services:7.8.0'
//    compile 'com.google.apis:google-api-services-youtube:v3-rev149-1.20.0'
}

Here is a screenshot to show how I have the YouTube API saved in the libs folder. enter image description here

I followed the instructions from the Google Developers guide to download the zip file and understand which jars needed to be copied over. These instructions include the following:

Dependencies for all Platforms

The following are the jars from the libs folder required for applications on all platforms:
google-api-client-1.20.0.jar
google-oauth-client-1.20.0.jar
google-http-client-1.20.0.jar
jsr305-1.3.9.jar
google-http-client-gson-1.20.0.jar (when using GSON) gson-2.1.jar
google-http-client-jackson2-1.20.0.jar (when using Jackson 2) jackson-core-$2.1.3.jar
google-http-client-jdo-1.20.0.jar (when using JDO) jdo2-api-2.3-eb.jar

Android Dependencies

The following are the jars from the libs folder required for android applications or a newer compatible version of each dependency:
google-api-client-android-1.20.0.jar (for SDK >= 2.1)
google-http-client-android-1.20.0.jar

Finally, I looked at the project structure, and it looks great here:

enter image description here

So why doesn't this thing resolve to a type? I'm completely at a loss. Thanks for any advice.

Upvotes: 3

Views: 1436

Answers (1)

Sebastiano
Sebastiano

Reputation: 12339

You have included the wrong YouTube SDK.

YouTubePlayerSupportFragment is part of the YouTube Player API package, that you can find here: https://developers.google.com/youtube/android/player/

Just download the JAR archive, put it in your 'libs' folder, and you'll be good to go.

Upvotes: 1

Related Questions