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

查看:193
本文介绍了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 Level 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

这是我的应用文件:

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天全站免登陆