android studio 3.2 无法解析 ':app@debug/compileClasspath' : Could not resolve com. android.support :appcompat-v7:27. 1.1 的依赖关系

标签 android android-studio gradle gradle-dependencies android-appcompat

我正在使用 android studio 3.2,在使用这个之前我安装了 android studio 2.2。当我打开一个新项目时,我会收到下面提到的这些错误。我想再次提及,我没有对布局或 main.activity 进行任何更改。我已经检查了旧版本的解决方案,但问题仍然存在。这是我之前尝试过的:

将应用插件:'com.android.application'更改为应用插件:'com.android.library' - 取消选中离线模式。 - 添加存储库:

mavenCentral()
        maven {
            url "https://maven.google.com"
    }

- 将 appcompat 更改为旧版本(v7:26+ 或 v7:25) 以下是错误日志:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.0.1.
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.constraint:constraint-layout:1.0.1.
Open File
Show Details


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


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12.
Open File
Show Details


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


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


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve junit:junit:4.12.
Open File
Show Details

--> 我的 gradle.wrapper.properties

#Thu Sep 27 09:39:31 EET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists zipStoreBase\=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip

--> 我的build.gradle(app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "com.example.a26033623.myapplication"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'
}

--> build.gradle(项目)

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

buildscript {

    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'


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

我真的纠结了2天浏览解决方案,我真的很迷茫。提前感谢您的时间、关注和帮助。

最佳答案

试试这个方法

1) Android Studio 3.1.4

2)

COMPILE_SDK_VERSION=26
BUILD_TOOLS_VERSION=27.0.3
TARGET_SDK_VERSION=26

3)

build.gradle{project}

buildscript {
    repositories {
        jcenter()
        google()
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'

    }
}

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

}

4) 支持库版本应该相同,您可以使用 26.1.0 进行上述配置,例如 com.android.support:appcompat-v7:26.1.0

5) 最后一步是

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

关于android studio 3.2 无法解析 ':app@debug/compileClasspath' : Could not resolve com. android.support :appcompat-v7:27. 1.1 的依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52532498/

相关文章:

java - 在某些设备上,应用程序未显示在 Play 商店中

filter - 从Gradle中的FileTree中排除文件

java - Android 客户端 - Java 服务器和 Tor 流量

android - MapView 中的 Fragment 内存泄漏

Android:包名用哪个? Manifest 的 packagename 或 Gradle applicationId?

android - 错误 :Cause: unable to find valid certification path to requested target

android - 如何添加 mopub 广告库与 android studio 的集成

java - Gradle 构建问题 : upgrading Quickblox and httpclient on latest Android SDK23

android - 在某些设备中抛出 java.lang.NoClassDefFoundError,但不是全部

android - 如何为 DialogPreference 子类正确实现 onRestoreInstanceState()?