【问题标题】:I'm a new android coder. I have the error "Gradle build finished with 242 error(s) and 2 warning(s)"我是一个新的 android 编码器。我有错误“Gradle 构建完成,出现 242 个错误和 2 个警告”
【发布时间】:2016-12-02 00:44:54
【问题描述】:

我正在尝试在 android 中编写一个 youtube 应用程序。我尝试使用此示例 https://developers.google.com/youtube/v3/docs/search/list#examples (Java#1)。我只使用了其中的导入语句,并且在尝试编译时出现了很多错误。我不确定如何导入库,首先我尝试从 Internet 下载库,但没有成功,尽管红色错误行移动到更多单词(例如红色错误之前的“import thing.thing2.thing3”线在事物下方,然后移至事物2)。然后我搜索了 mvnrepository 并将“gradle”选项卡下的代码复制并粘贴到我的 gradle 中,它修复了红色错误行但现在我在尝试运行我的应用程序时遇到了很多错误(我的应用程序中没有任何红线据我所知)。我的 gradle 文件看起来像:

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 24
        buildToolsVersion "23.0.3"

        defaultConfig {
            applicationId "richardcastle324.yahoo.com.elephantyoutube"
            minSdkVersion 15
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
            compile fileTree(include: ['*.jar'], dir: 'libs')
            testCompile 'junit:junit:4.12'
            compile 'com.android.support:appcompat-v7:24.0.0'
            compile files('libs/YouTubeAndroidPlayerApi.jar')
            compile 'com.google.android.gms:play-services-drive:8.4.0'
            compile files('libs/google-api-client-1.16.0-rc-sources.jar')
            compile files('libs/google-api-services-youtube-v3-rev176-1.22.0-javadoc.jar')
            compile 'com.google.android.gms:play-services:9.2.0'
            compile 'com.google.apis:google-api-services-youtube:v3-rev176-1.22.0'
            // https://mvnrepository.com/artifact/com.google.apis/google-api-services-youtube
            compile group: 'com.google.apis', name: 'google-api-services-youtube', version: 'v3-rev176-1.22.0'
            // https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client-java6
            compile group: 'com.google.oauth-client', name: 'google-oauth-client-java6', version: '1.11.0-beta'
            // https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client-jetty
            compile group: 'com.google.oauth-client', name: 'google-oauth-client-jetty', version: '1.11.0-beta'                
}

【问题讨论】:

  • 发布错误信息

标签: android api gradle youtube


【解决方案1】:

我不完全确定所有这些依赖项在做什么,但我有一个基本的 youtube 应用程序,它使用以下构建 gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "com.example.jakespeers.youtubeplayer"
    minSdkVersion 16
    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'])
testCompile 'junit:junit:4.12'
compile files("libs/YouTubeAndroidPlayerApi.jar")
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services:8.4.0'
}

只要确保您的 libs 文件夹中有“YouTubeAndroidPlayerApi.jar”文件即可。通过进入应用程序名称文件夹找到 libs 文件夹,然后是“app”文件夹,最后是“libs”文件夹。确保文件拼写完全相同。也不要忘记更改您的 applicationId。如果您需要更多依赖项,您可以根据需要添加它们。

如果这仍然不起作用,请发布您遇到的错误。

这里是下载lib文件的链接: https://developers.google.com/youtube/android/player/downloads/

【讨论】:

    猜你喜欢
    • 2018-09-06
    • 1970-01-01
    • 2017-12-09
    • 2017-12-22
    • 2016-10-05
    • 1970-01-01
    • 2015-10-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多