Gradle 构建错误:无法解决: [英] Gradle build error: Failed to resolve:

查看:27
本文介绍了Gradle 构建错误:无法解决:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚下载了 Android Studio 并创建了一个新项目,但出现了 gradle 构建错误:

I just downloaded Android Studio and created a new project and I'm getting gradle build errors:

无法解析:com.android.support.test.espresso-core:2.2.2

Failed to resolve: com.android.support.test.espresso-core:2.2.2

无法解析:com.android.support.appcompat-v7:25.3.1

Failed to resolve: com.android.support.appcompat-v7:25.3.1

以管理员身份启动 android studio 时重新安装 SDK Tools + Repository + API 解决了此错误.

我已经安装了我想要构建的 API 级别 25,并且已经下载了 SDK Build-Tools.我也已经下载了支持库

I've installed API Level 25 which what I want to build on and have downloaded the SDK Build-Tools. I have also already download the support repository

这是我的应用程序文件:

Here's my app file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.3'
    defaultConfig {
        applicationId "com.jtsalas.mirrorcontrol"
        minSdkVersion 25
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_7
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    testCompile 'junit:junit:4.12'
}

build.gradle:

build.gradle:

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

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

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

allprojects {
    repositories {
        jcenter()
    }
}

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

推荐答案

从 SDK 管理器中,确保您安装了 Android Support Repository 和 Google Repository 并且是最新的.然后,您应该能够在/extras/android/m2repository 目录的子文件夹中找到相关工件

From the SDK manager, make sure you have both the Android Support Repository and Google Repository installed and up to date. You should then be able to find the relevant artifacts in sub folders of your /extras/android/m2repository directory

这篇关于Gradle 构建错误:无法解决:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆