【问题标题】:Error:Could not resolve com.android.support:appcompat-v7:26.0.0-beta1错误:无法解析 com.android.support:appcompat-v7:26.0.0-beta1
【发布时间】:2017-12-23 20:52:32
【问题描述】:

我已经在 macbook pro 上安装了 android studio,我确信我已经安装了所有必需的 SDK 以使其工作,但我仍然遇到错误问题。以下是错误信息

无法解析 ':app@debug/compileClasspath' 的依赖关系:无法解析 com.android.support:appcompat-v7:26.0.0-beta1。

无法解析 com.android.support:appcompat-v7:26.0.0-beta1。 要求:项目:app

没有可用于离线模式的 com.android.support:appcompat-v7:26.0.0-beta1 的缓存版本。

这是我的毕业作品

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.air.my1st"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.0.0-beta1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:0.5'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}

提前谢谢大家。

【问题讨论】:

  • google() 添加到项目的 build.gradle 文件中的两个 repositories 闭包中。然后,将您的 26.0.0-beta1 依赖项切换到 26.1.0
  • 我已经在两个存储库中都有 google() @CommonsWare
  • 感谢在将 26.0.0-beta1 依赖项切换到 26.1.0 后它工作正常...感谢 @CommonsWare 兄弟

标签: android


【解决方案1】:

在 build.gradle 中添加这段代码:

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

【讨论】:

  • 考虑解释为什么这些行可以解决问题。
【解决方案2】:

尝试更改targetSdkVersion 27

依赖到最新:

implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:design:27.1.1'

【讨论】:

    猜你喜欢
    • 2018-06-05
    • 2018-01-03
    • 1970-01-01
    • 1970-01-01
    • 2021-02-26
    • 2017-01-03
    • 1970-01-01
    • 2015-05-30
    相关资源
    最近更新 更多