redoc01
redoc01

Reputation: 2325

Android - package com.google.android.youtube.player does not exist

I cant seem to compile my App in Androoid Studio, i am trying to use the Android Youtube Player API. I have included the AndroidYoutubePlayerApi.jar in my libs folder:

Here is what i have done:

build.gardle (Module:App)

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.1"

        defaultConfig {
        applicationId "com.xxx.xxx.xxx"
        minSdkVersion 15
        targetSdkVersion 23
        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:23.1.1'
        compile files('libs/YouTubeAndroidPlayerApi.jar')
        compile 'com.google.apis:google-api-services-youtube:v3-rev125-1.19.1'
    }

Added user-permissions in AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

But cant seem to compile and import com.google.android.*;

I have downloaded all the SDK Tools aswel.

Update:

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.google.android.gms:play-services:8.4.0'
    }

Upvotes: 2

Views: 3329

Answers (1)

Stargazing Worm
Stargazing Worm

Reputation: 151

I know this is an old question, but it scores high on Google for this error message, so I thought I'd supply my solution here.

I'm using Android Studio to build an Ionic app that uses the YouTube player (by way of the cordova-plugin-youtube-video-player). This may not be identical to what other people are trying to do, but this solution may point them in the right direction.

I go to "File > Project Structure ..." In the left-hand panel, there's a list of things. Under "Modules" is the name of the project I'm building ("app"). View of the Project Structure dialog box

Clicking on "app" and then clicking on the dependency tab, I manually add dependencies for the YouTubeAndoridPlayerApi.jar and openyoutubeactivity.jar as "implementation" dependencies.

View of the dependencies tab

Why the include of "*.jar" in the "libs" directory doesn't perform that include, I'm not sure. But when I added the dependencies explicitly, my project successfully compiles.

Upvotes: 2

Related Questions