Android无法找到com.android.support

时间:2015-05-24 12:59:19

标签: android gradle build.gradle

我正在尝试从gradle安装Android android.support库,但是我收到此错误:

Error:Failed to find: com.android.support:cardview-v7:21.0.0

Error:Failed to find: com.android.support:support-v4:21.0.3

Error:Failed to find: com.android.support:recyclerview-v7:21.0.0

Error:Failed to find: com.android.support:appcompat-v7:21.0.3

我的完整build.gradle

apply plugin: 'com.android.application'
android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "br.com.halyson.materialdesign"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0.0"
    }
    buildTypes {
        release {
            zipAlignEnabled true
            minifyEnabled false
            shrinkResources false
            debuggable false
            proguardFiles 'proguard-rules.pro'
        }

        debug {
            minifyEnabled false
            debuggable true
            proguardFiles 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:recyclerview-v7:21.0.0'
    compile 'com.android.support:cardview-v7:21.0.0'
    compile 'com.squareup:otto:1.3.5'
    compile 'com.squareup.picasso:picasso:2.3.4'
    compile 'com.squareup.okhttp:okhttp:2.1.+'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.+'
    compile 'com.squareup.retrofit:retrofit:1.8.+'
    compile 'com.melnykov:floatingactionbutton:1.1.0'
    compile 'com.github.ksoichiro:android-observablescrollview:1.4.0'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
}

我从Android SDK管理器安装了Android支持库和Android支持存储库。如何解决这个问题?或选择此支持的其他版本?

2 个答案:

答案 0 :(得分:0)

从项目内的文件夹libs中删除* .jar(包含错误的库)。然后清除项目。然后建立。

还要确保{jar}文件存在于\\sdk\extras\...子文件夹

答案 1 :(得分:0)

尝试将依赖项更改为

compile 'com.android.support:support-v4:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:recyclerview-v7:22.1.1'
compile 'com.android.support:cardview-v7:22.1.1'