Android - 软件包com.google.android.youtube.player不存在

问题描述 投票:2回答:1

我似乎无法在Android Studio中编译我的应用程序,我正在尝试使用Android Youtube Player API。我在我的libs文件夹中包含了AndroidYoutubePlayer Api.jar:

这就是我所做的:

build.gradle(模块: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'
    }

在AndroidManifest.xml中添加了用户权限:

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

但似乎无法编译和导入com.google.android。*;

我已经下载了所有SDK工具aswel。

更新:

    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'
    }
java android android-youtube-api
1个回答
2
投票

我知道这是一个老问题,但是谷歌在这个错误信息上得分很高,所以我想我会在这里提供我的解决方案。

我正在使用Android Studio构建一个使用YouTube播放器的Ionic应用程序(通过cordova-plugin-youtube-video-player)。这可能与其他人试图做的不一样,但这种解决方案可能会指向正确的方向。

我转到“文件>项目结构......”在左侧面板中,有一个列表。在“模块”下面是我正在构建的项目的名称(“app”)。 View of the Project Structure dialog box

单击“app”然后单击依赖选项卡,我手动添加YouTubeAndoridPlayerApi.jar和openyoutubeactivity.jar的依赖项作为“实现”依赖项。

View of the dependencies tab

为什么在“libs”目录中包含“* .jar”不执行包含,我不确定。但是当我明确添加依赖项时,我的项目成功编译。

© www.soinside.com 2019 - 2024. All rights reserved.