摇篮找不到依赖(Android的支持库) [英] Gradle can't find dependency (Android support library)

查看:145
本文介绍了摇篮找不到依赖(Android的支持库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有摇篮找不到我的依赖(Android的支持库)中的问题。

I have a problem that Gradle can't find my dependency (Android support library).

我的build.gradle看起来是这样的:

My build.gradle looks like this:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    compile files('libs/FlurryAgent.jar')
    compile group: 'com.google.android', name: 'support-v4', version: 'r7'
    compile files('libs/YouTubeAndroidPlayerApi.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17"

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 17
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        instrumentTest.setRoot('tests')
    }
}

当我建立(在命令行,没有IDE)我得到以下信息:

When I build (on commandline, no IDE) I get the following message:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'AndroidCalculator'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':compile'.
      > Could not find com.google.android:support-v4:r7.
        Required by:
            :AndroidCalculator:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

我为什么不允许添加Android的支持库也是这样吗?

Why am I not allowed to add the Android Support library like this?

推荐答案

您已经申报了的库的依赖的,但还没有宣布的的。因此,依赖关系不能得到解决。 (库/在 buildscript 块依赖严格从主构建脚本库/依赖性分开。)

You have declared a repository dependency, but haven't declared a repository. Hence the dependency cannot be resolved. (Repositories/dependencies in the buildscript block are strictly separated from repositories/dependencies in the main build script.)

这篇关于摇篮找不到依赖(Android的支持库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆