android - 将 Android Studio 更新到 3.1.3 后依赖项出现一些错误

标签 android gradle build dependencies android-studio-3.1

您好,我在构建时遇到了一些错误... 我是 android studio 的新手 在我将我的 android studio 更新到 3.1.3 之前我没有问题...... 现在我在 gradle build 上播报关于 Unable to resolve dependency for ... 的错误

这是我的 build.gradle(Module: app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.shoaib.newsletters"
        minSdkVersion 18
        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.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    compile 'com.tomerrosenfeld.customanalogclockview:custom-analog-clock-view:1.1'
    compile 'com.android.volley:volley:1.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
}

和我的 build.gradle(Project:)

// 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.3'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

还有错误

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File
Show Details


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


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File
Show Details

请告诉我如何解决这些问题...

最佳答案

当您使用 appcompact-v7:26.1.0 时

你的约束布局版本必须是

implementation 'com.android.support.constraint:constraint-layout:1.0.2'

测试应该是

androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

如果对你有帮助,欢迎更新

关于android - 将 Android Studio 更新到 3.1.3 后依赖项出现一些错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50797334/

相关文章:

android - Kotlin 协程resumeWithException 错误

java - 应用程序不适合所有显示尺寸

gradle - 不是从链接下载工件

android - 错误 : Unable to resolve dependency in android studio 3. 4

android - 签名 apk 时构建失败

android - Dalvik VM 找不到多种方法

android - Android Studio 3.5.0上的Gradle错误 'variant.getMergeResources()'

java - 依赖更新后gradle构建失败

google-chrome-extension - 我可以拥有基于保存构建的 Aurelia 文件版本吗?

Makefile 每隔一段时间就会忽略依赖关系