Android支持库 - 无法解决

时间:2017-08-02 02:54:46

标签: android gradle android-support-library

我正在尝试将以下支持库添加到我的buid.gradle:

 buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    }
}

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {
    useLibrary 'org.apache.http.legacy'

    compileSdkVersion 26
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 26

    }

    signingConfigs {
        release {

        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

repositories {
    jcenter()
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.android.support:support-v7:26.0.0'
    compile 'com.android.support:appcompat-v7:26.0.0'
    compile 'com.android.support:cardview-v7:26.0.0'
    compile 'com.melnykov:floatingactionbutton:1.1.0'
    compile 'it.sephiroth.android.library.imagezoom:imagezoom:1.0.5'
    //Apptentive
    compile 'com.apptentive:apptentive-android:2.1.3@aar'
    //compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.0.0'

}

我收到错误,说明每个库“无法解析”,后面跟着上面的每行代码。我希望能够继续使用最新的支持库来获得常规支持,appcompat和cardview。

2 个答案:

答案 0 :(得分:9)

要从版本26.0.0开始使用支持库,您需要将Google的Maven存储库添加到项目的build.gradle文件中,如here所述。

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

答案 1 :(得分:1)

你的buildToolsVersion和compileSdkVersion是什么?

android {
    buildToolsVersion "26.0.1"
}

也许尝试在AndroidManifest.xml中更新它?有时它们不兼容,您必须相应地修改版本。

此链接可能有所帮助:Setting up Gradle for api 26 (Android)

相关问题