当前位置: 首页 > 知识库问答 >
问题:

Gradle构建Android项目“无法解决所有依赖项”错误

孔山
2023-03-14

我试图用Gradle构建我的第一个项目,我认为我的gradle文件和设置是正确的。

我只使用一个模块并支持V4 AppCompatBar库。

项目-build.gradle

allprojects {
    repositories {
        mavenCentral()
    }
}

Project-settings.gradle

include ':AssignmentTempos21'

主模块-build.gradle

buildscript {
    repositories {
        mavenCentral()
    }

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

apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 17
    }
}

dependencies {
    compile "com.android.support:support-v4:18.0.+"
    compile "com.android.support:appcompat-v7:18.0.+"
}

带有-i标志的控制台输出:

MacBook-Air-de-Cesar-2:AssignmentTempos21 menor$ ./gradlew -i clean assemble
Starting Build
Settings evaluated using settings file '/Users/menor/workspace_android/AssignmentTempos21/settings.gradle'.
Projects loaded. Root project using build file '/Users/menor/workspace_android/AssignmentTempos21/build.gradle'.
Included projects: [root project 'AssignmentTempos21', project ':AssignmentTempos21']
Evaluating root project 'AssignmentTempos21' using build file '/Users/menor/workspace_android/AssignmentTempos21/build.gradle'.
Compiling build file '/Users/menor/workspace_android/AssignmentTempos21/build.gradle' using BuildScriptClasspathScriptTransformer.
Compiling build file '/Users/menor/workspace_android/AssignmentTempos21/build.gradle' using BuildScriptTransformer.
Evaluating project ':AssignmentTempos21' using build file '/Users/menor/workspace_android/AssignmentTempos21/AssignmentTempos21/build.gradle'.
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/support-v4/]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/maven-metadata.xml]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/maven-metadata.xml]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/maven-metadata.xml]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/maven-metadata.xml]
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/com/android/support/appcompat-v7/]

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':AssignmentTempos21'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':AssignmentTempos21:_DebugCompile'.
      > Could not find any version that matches com.android.support:support-v4:18.0.+.
        Required by:
            AssignmentTempos21:AssignmentTempos21:unspecified
      > Could not find any version that matches com.android.support:appcompat-v7:18.0.+.
        Required by:
            AssignmentTempos21:AssignmentTempos21:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Total time: 40.787 secs

共有1个答案

葛威
2023-03-14

正如彼得所说,他们不会在马文中心

从Android SDK管理器下载“Android支持存储库”,支持库的Maven repo将下载到您的Android SDK目录(请参阅“extras”文件夹)

要将库部署到本地. m2存储库,您可以使用maven-android-sdk-部署器

2017年编辑:

您现在可以参考谷歌在线M2回购协议

repositories {
google()
jcenter()
}
 类似资料:
  • 问题是gradle找不到依赖项的jar,但gradle找错了地方。Gradle一直在错误的目录(谷歌和Android支持libary的目录)中搜索文件.... 在以下位置搜索:文件:/d://programme/androis-sdks/extras/android/m2repository/org/springframework/android/spring-android-rest-templ

  • 我的应用程序的build.gradle如下所示:应用插件:'com.android.application' 我尝试过更改存储库(jcenter()、mavenCentral()等)、重新安装Android Studio、JDK(7和8)、更改Gradle版本和Android SDK版本,这些都没有奏效。运行./gradlew build时,我得到: 这是我在其他情况下也会遇到的错误,例如,当尝试

  • 由于butterknife依赖的错误,我无法构建android项目。 错误 任务': app: javaPreCompileDebug'执行失败。 无法解析配置的所有文件: app: dedegAnnotationProcessorClasspath。转换butterknife-compiler-8.6.0.jar失败(com.jakewharton:巴特切夫-编译器: 8.6.0)以匹配属性{a

  • 几天来,我一直在尝试使用nativescript。我的所有安装都进行得很好,但在执行tns运行的android——emulator时,它给了我以下错误: MiC@USERMINGW32 ~/Android项目/HelloWorld$tns运行Android搜索设备。。。跳过准备。正在生成项目。。。Gradle构建。。。 失败:生成失败,出现异常。 > 问题:配置根项目“HelloWorld”时出现

  • 我对Android的Gradle构建有问题。我尝试了很多方法来解决这个问题,但没有什么不起作用。我需要帮助。 Gradle版本:4.4 Gradle插件:3.0.1 错误:无法解析app@serverDebug /compileClasspath的依赖关系:无法解析项目:vksdk_library。 错误:无法解析“”的依存关系:app@mockDebugAndroidTest/compileCl

  • 我无法构建gradle项目,即使我编辑gradle属性,我也会得到以下错误: 我该如何解决这个问题?