错误:无法解析所有配置文件':app:debugCompileClasspath'

时间:2017-12-08 14:53:27

标签: android

以下是来自日志的完整消息: 错误:无法解析所有配置文件':app:debugCompileClasspath'。

  

找不到com.android.support:appcompat-v7:26.1.0。     在以下位置搜索:         文件:/ C:/Users/Anatoly/AppData/Local/Android/Sdk/extras/m2repository/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom         文件:/ C:/Users/Anatoly/AppData/Local/Android/Sdk/extras/m2repository/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.jar         文件:/ C:/Users/Anatoly/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom         文件:/ C:/Users/Anatoly/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.jar         文件:/ C:/Users/Anatoly/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom         文件:/ C:/Users/Anatoly/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.jar         文件:/ C:/android/AndroidStudio/gradle/m2repository/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom         文件:/ C:/android/AndroidStudio/gradle/m2repository/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.jar     要求:         项目:app

我的 gradle-wrapper.properties

distributionUrl = HTTPS://services.gradle.org/distributions/gradle-4.1-all.zip

我的 build.gradle of project

buildscript {
    repositories {
        // Gradle 4.1 and higher include support for Google's Maven repo using
        // the google() method. And you need to include this repo to download
        // Android plugin 3.0.0 or higher.
        google()
        maven { url "https://maven.google.com" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

我的 build.gradle of app

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26



    defaultConfig {
        applicationId "ru.foodrobot.test2"
        minSdkVersion 10
        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'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

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

4 个答案:

答案 0 :(得分:10)

我修改了项目级别 /gradle.build

allprojects {
repositories {
    jcenter()

收件人:

allprojects {
repositories {
    jcenter { url "http://jcenter.bintray.com/"}

在文件中:

platforms/android/build.gradle

答案 1 :(得分:1)

将gradle.properties文件重命名为xgradle.properties并尝试:

ionic cordova build android --prod 

它将正常工作。

答案 2 :(得分:0)

我也遇到了类似的问题

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':app:stgCompileClasspath'.
> Could not resolve com.google.android.gms:play-services-appinvite:[15.0.1,16.0.0).
  Required by:
      project :app > com.google.firebase:firebase-invites:15.0.1
   > Could not resolve com.google.android.gms:play-services-appinvite:[15.0.1,16.0.0).
      > Failed to list versions for com.google.android.gms:play-services-appinvite.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/android/gms/play-services-appinvite/maven-metadata.xml.

除了为构建脚本中的依赖关系正确映射存储库之外,我所做的还有以下事情:

  • 清除我的构建工作区(干净的构建,只需再次签出我的代码)-borjalo's answer
  • 清除GRADLE_USER_HOME(已删除.gradle目录,因为我的构建也抱怨守护进程繁忙)

希望这会有所帮助。

答案 3 :(得分:-1)

在项目级别的存储库中添加google()并单击立即同步,错误将消失。如

<强>的build.gradle(项目:XXX)

repositories {
   google()//new 
   jcenter()
}