android - Build.gradle : Failed to resolve: com. android.support

标签 android android-studio gradle android-gradle-plugin

我正在尝试构建我的 Android Studio 项目,但我一直收到“解析失败:com.android.support”错误。

这是 build.gradle 的样子:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "app.training.linus.trainingapp"
        minSdkVersion 26
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.exercise_card.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:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.google.android.gms:play-services-plus:15.0.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.exercise_card:runner:1.0.2'
    androidTestImplementation 'com.android.support.exercise_card.espresso:espresso-core:3.0.2'
}

还有另一个gradle文件:

// 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
}

我不明白为什么我无法正确构建,我下载了正确的 SDK 版本和所有内容。

提前致谢!

最佳答案

删除

androidTestImplementation 'com.android.support.exercise_card:runner:1.0.2'
androidTestImplementation 'com.android.support.exercise_card.espresso:espresso-core:3.0.2'

好像解决了!

关于android - Build.gradle : Failed to resolve: com. android.support,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51232488/

相关文章:

java - Android中如何在不锁定UI线程的情况下等待?

android-studio - 需要等级版本 2.6。当前版本是 2.4

android-studio - Android Studio 无法定位 adb 问题

android - 运行react-native run-android时的一些问题

gradle - 如何在包装器任务中设置分发类型

java - java中不可解析的日期异常

java - 为什么我从浏览器获得了正确的 URL 响应,但 Android 的 "HttpGet"中却是空的?

Android Activity 作为对话框,但没有标题栏

java - 从 Android 设备调用 .Net 网络服务

java - 将Java编译器标志添加到android gradle项目中除 Protocol Buffer 之外的所有内容