找不到com.android.support:support-annotations:26.1.0

时间:2018-07-02 05:07:32

标签: android sdk

我有一个项目,其compileSdkVersiontargetSdkVersion为25。当我尝试将版本升级到26时,出现以下错误:

Could not find com.android.support:support-annotations:26.1.0.
Required by:
    project :app
    project :app > com.android.support:support-compat:26.1.0

Please install the Android Support Repository from the Android SDK Manager.
Open Android SDK Manager

我打开了Android SDK Manager,但是找不到要安装的Android支持存储库。

如何解决此问题?

这是我的应用程序和项目gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.3'

    defaultConfig {
        //my default config
    }

    signingConfigs {
        config {
            //config
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        debug {
            versionNameSuffix ".debug"
        }
    }

    lintOptions {
        /*disable 'InvalidPackage'*/
        abortOnError false
    }

    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "http://dl.bintray.com/populov/maven" }
        maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases' }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

def support = '26.1.0'
def rounded_image_view = "2.3.0"

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile "com.android.support:support-annotations:$support"
    compile "com.android.support:appcompat-v7:$support"
    compile "com.android.support:support-v4:$support"
    compile "com.android.support:design:$support"
    compile "com.android.support:cardview-v7:$support"
    compile "com.android.support:recyclerview-v7:$support"
    compile "com.android.support:support-vector-drawable:$support"
    compile "com.android.support:support-compat:$support"
    compile "com.android.support:support-core-ui:$support"
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.wrapp.floatlabelededittext:library:0.0.6'
    /*compile 'javax.inject:javax.inject:1'*/

    //needed to resolve compilation errors, thanks to tutplus.org for finding the dependency
    compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
    compile 'com.balysv.materialmenu:material-menu:1.5.2'
    compile 'com.flyco.dialog:FlycoDialog_Lib:1.1.6@aar'
    compile 'com.flyco.animation:FlycoAnimation_Lib:1.0.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0@aar'
    compile 'com.norbsoft.typefacehelper:library:0.9.0'
    compile 'com.quinny898.library.persistentsearch:library:1.1.0-SNAPSHOT'
    compile 'com.rengwuxian.materialedittext:library:2.1.4'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'jp.wasabeef:picasso-transformations:2.1.0'
    compile 'com.tuenti.smsradar:library:1.0.4'
    compile 'com.viewpagerindicator:library:2.4.1@aar'
    compile 'com.xgc1986.android:parallaxpagertransformer:1.0.3'
    compile 'com.github.medyo:fancybuttons:1.5@aar'
    compile 'com.google.code.ksoap2-android:ksoap2-android:2.6.5'
    compile 'com.google.dagger:dagger:2.0.1'
    compile('com.github.afollestad.material-dialogs:core:0.8.5.3@aar') { transitive = true }
    compile 'com.google.android.gms:play-services-gcm:11.0.4'
    compile 'me.relex:circleindicator:1.2.2@aar'
    compile 'com.github.rubensousa:gravitysnaphelper:1.1'
    compile 'com.miguelcatalan:materialsearchview:1.4.0'
    compile 'com.makeramen:roundedimageview:2.3.0'
    compile 'com.journeyapps:zxing-android-embedded:3.5.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'org.jsoup:jsoup:1.8.3'
    apt "com.google.dagger:dagger-compiler:2.0.1"
    provided 'org.glassfish:javax.annotation:10.0-b28'
    androidTestCompile(
            'org.mockito:mockito-core:1.9.5',
            'org.hamcrest:hamcrest-core:1.1',
            'org.hamcrest:hamcrest-integration:1.1',
            'org.hamcrest:hamcrest-library:1.1'
    )

    compile 'com.romandanylyk:pageindicatorview:0.2.0@aar'
    compile 'ca.barrenechea.header-decor:header-decor:0.2.8'
    compile "com.makeramen:roundedimageview:$rounded_image_view"
    compile 'cz.msebera.android:httpclient:4.4.1.2'
    compile 'de.hdodenhof:circleimageview:2.2.0'


}

apply plugin: 'com.google.gms.google-services'

并且:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
        classpath 'io.fabric.tools:gradle:1.22.1'
    }
}

allprojects {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        maven { url "https://jitpack.io" }
        mavenCentral()
        jcenter()
    }

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }
    }
}

4 个答案:

答案 0 :(得分:5)

我回答了我自己的问题:

maven { url 'https://maven.google.com' }添加到:

allprojects {
    repositories {
        ...
        maven { url 'https://maven.google.com' }//this line is added
        mavenCentral()
        jcenter()
    }
}

为我工作是因为我的gradle版本是3.x。我认为@shizhen的答案也是正确的,但应将gradle版本更改为4.x+

有关更多信息,请参见difference between google() and maven { url 'https://maven.google.com' }

答案 1 :(得分:3)

尝试在您的buildscripts块中添加“ google()”回购。

#lang racket

(struct account (balance))

(define new-account (account 0))

(define/contract (balance acc)
  (-> account? number?)
  (account-balance acc))

(define/contract (deposit acc amt)
  (-> account? (and/c real? positive?) account?)
  (account (+ (account-balance acc) amt)))

(displayln (balance (deposit new-account -10)))

还可以在 gradle-wrapper.properties

中将gradle包装器版本更改为4.1
buildscript {
    repositories {
        google() // add this new line. 
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
    }

    dependencies {
        //classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.android.tools.build:gradle:3.0.1' // change the gradle plugin version to 3.0.1.
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
        classpath 'io.fabric.tools:gradle:1.22.1'
    }
}

如果仍然有问题,请尝试安装更高版本的Android Studio 3.1.2。

答案 2 :(得分:0)

这是 SDK管理器

中的Android Support Repository

enter image description here

答案 3 :(得分:0)

应将 google() 作为第一存储库,并将您的Android Gradle插件版本升级到3.0.1

classpath 'com.android.tools.build:gradle:3.0.1'