无法解析Dependencies app @ debug / compileClasspath Android Studio 3.0.1

时间:2022-09-03 22:31:01

as I started a new project, these errors popped up

当我开始一个新项目时,这些错误突然出现了

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.1.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.1.
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0. 
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.

These are the errors that were shown. Below is my build.gradle(Module:app)

这些是显示的错误。下面是我的build.gradle(模块:app)

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.example.user.myapplication"
    minSdkVersion 22
    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'
    }
}
buildToolsVersion '26.0.2'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-
    core:3.0.1'
}

build.gradle(Project:myapp)

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


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

gradle-wrapper.properties(Gradle Version)

#Sat Nov 25 20:44:59 SGT 2017
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

By the way, my gradle is 4.1 and my android studio is 3.0.1. Please help me how to solve this problem. Thank you.

顺便说一句,我的gradle是4.1,我的android studio是3.0.1。请帮我解决这个问题。谢谢。

1 个解决方案

#1


0  

Go to File >> Settings >> Build, Execution, Deployment >> Gradle menu. Uncheck "Offline work".

转到文件>>设置>>构建,执行,部署>> Gradle菜单。取消选中“离线工作”。

#1


0  

Go to File >> Settings >> Build, Execution, Deployment >> Gradle menu. Uncheck "Offline work".

转到文件>>设置>>构建,执行,部署>> Gradle菜单。取消选中“离线工作”。