Add Youtube Data API to Android Studio with Gradle

Android Studio cannot find the required YouTube classes in my application. I am recycling the code of a previous project. In a previous project, I just imported the jar file provided by Google. But I want to find out the best way using gradle. I used to use gradle with success. This is amazing when it works. I have already managed to add dependencies using gradle. But for some reason I can't get google lib to download or activate, or what it needs so that my IDE can find all these missing youtube characters. I did the usual synchronization with gradle and restored and cleaned up, and all this, but that did not help.

Here is my build.gradle file:

apply plugin: 'com.android.application' repositories { mavenCentral() } android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "dayspringwesleyan.org.dayspringwesleyanchurch" minSdkVersion 10 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { //compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.google.android.gms:play-services:7.5.0' compile 'com.google.apis:google-api-services-youtube:v3-rev141-1.20.0' compile 'com.koushikdutta.ion:ion:2.1.6' } 
+5
source share
1 answer

I'm not sure why Google no longer allows YouTube Player to be loaded into the application the way we are used to, but here is my current solution:

1) Try downloading the video using your youtube player device

 initYouTubePlayer(player, "3uyaO745g0s"); 

2) If you received SERVICE_MISSING in your onInitializationFailure , then pull the thumbnail for the video and let the user download the video in the browser

 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.youtube.com/watch?v=3uyaO745g0s")); YoutubeClipDetail.this.getContext().startActivity(intent); 
0
source

All Articles