【问题标题】:Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.0.0-beta1错误:无法解析“:app@debug/compileClasspath”的依赖关系:无法解析com.android.support:appcompat-v7:26.0.0-beta1
【发布时间】:2018-06-05 18:54:11
【问题描述】:

我有 android studio 2.3.3,我安装了 android studio 3.0.1。我无法同步项目

这是我的错误:

E:\AndroidProject\...\app\build.gradle
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.0.0-beta1. Open File Show Details

Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.0.0-beta1.

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.0-beta1. 
....

我的应用 build.gradle

    apply plugin: 'com.android.application'
            android {
        compileSdkVersion 26
        buildToolsVersion '26.0.2'
        defaultConfig {
            applicationId "com.avana.xxx"
            minSdkVersion 14
            targetSdkVersion 26
           ...
        }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support.constraint:constraint-layout:1.1.0-beta1'
    compile 'com.android.support:appcompat-v7:26.0.0-beta1'
    compile 'com.android.support:cardview-v7:26.0.0-beta1'
    compile 'com.android.support:design:26.0.0-beta1'
}

build.gradle

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

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

gradle.wrapper

  distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

【问题讨论】:

  • 嗨。在这里发帖时,请专注于您的问题,而不是诸如“你好”、“请帮助我”之类的闲聊材料,也不要为了打败问题过滤器而复制和粘贴它。结果是一堆乞讨,为志愿编辑创造了新的工作。

标签: android


【解决方案1】:

只需在 build.gradle 中更改(项目:testApp),

按照顺序就完成了,你需要在repositories和allprojects repositories中添加google,顺序,不要忘记添加“task clean(..){.. }"

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

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

    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

【讨论】:

  • 您只需粘贴 gradle 文件。我们在这个文件中做什么。请为所有人发布答案
  • 只要确保正确执行第 2 步即可。第1步仅供参考。
  • 请明确说明你在做什么
【解决方案2】:

转到setting->build->gradle,然后取消选中offline-work 按钮。然后重建你的程序。

这是same problem as yours

【讨论】:

猜你喜欢
  • 2018-05-11
  • 2018-04-10
  • 1970-01-01
  • 1970-01-01
  • 2018-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多