gpt4 book ai didi

android - Gradle无法解决所有依赖关系

转载 作者:行者123 更新时间:2023-12-03 06:16:02 27 4
gpt4 key购买 nike

我正在尝试一件简单的事情:导入一些Google的库以使用Gmail API。我知道其中一些jar在mavenCentral上不存在。因此,我从sdk经理更新了我的Google Repository,并指示gradle查看sdk。我还删除了依赖项末尾的版本号,并用+代替了它,但不能解决我的问题,因此退回到original build.gradle文件。

我的build.gradle文件如下所示:

buildscript {
repositories {
mavenCentral()


def androidHome = System.getenv("ANDROID_HOME")
maven {
url "$androidHome/extras/android/m2repository/"
}
}


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

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
applicationId "com.hellobusiness.hotels"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.google.api-client:google-api-client:1.20.0'
compile 'com.google.api-client:google-api-client-android:1.20.0'
compile 'com.google.api-client:google-api-client-gson:1.20.0'
compile 'com.google.apis:google-api-services-gmail:v1-rev29-1.20.0'
}

我得到的错误:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'Hotels'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
> Could not find com.google.api-client:google-api-client:1.20.0.
Searched in the following locations:
file:/home/sanctus/adt/sdk/extras/android/m2repository/com/google/api-client/google-api-client/1.20.0/google-api-client-1.20.0.pom
file:/home/sanctus/adt/sdk/extras/android/m2repository/com/google/api-client/google-api-client/1.20.0/google-api-client-1.20.0.jar
file:/home/sanctus/adt/sdk/extras/google/m2repository/com/google/api-client/google-api-client/1.20.0/google-api-client-1.20.0.pom
file:/home/sanctus/adt/sdk/extras/google/m2repository/com/google/api-client/google-api-client/1.20.0/google-api-client-1.20.0.jar
Required by:
:Hotels:unspecified
> Could not find com.google.api-client:google-api-client-android:1.20.0.
Searched in the following locations:
file:/home/sanctus/adt/sdk/extras/android/m2repository/com/google/api-client/google-api-client-android/1.20.0/google-api-client-android-1.20.0.pom
file:/home/sanctus/adt/sdk/extras/android/m2repository/com/google/api-client/google-api-client-android/1.20.0/google-api-client-android-1.20.0.jar
file:/home/sanctus/adt/sdk/extras/google/m2repository/com/google/api-client/google-api-client-android/1.20.0/google-api-client-android-1.20.0.pom
file:/home/sanctus/adt/sdk/extras/google/m2repository/com/google/api-client/google-api-client-android/1.20.0/google-api-client-android-1.20.0.jar
Required by:
:Hotels:unspecified
> Could not find com.google.api-client:google-api-client-gson:1.20.0.
Searched in the following locations:
file:/home/sanctus/adt/sdk/extras/android/m2repository/com/google/api-client/google-api-client-gson/1.20.0/google-api-client-gson-1.20.0.pom
file:/home/sanctus/adt/sdk/extras/android/m2repository/com/google/api-client/google-api-client-gson/1.20.0/google-api-client-gson-1.20.0.jar
file:/home/sanctus/adt/sdk/extras/google/m2repository/com/google/api-client/google-api-client-gson/1.20.0/google-api-client-gson-1.20.0.pom
file:/home/sanctus/adt/sdk/extras/google/m2repository/com/google/api-client/google-api-client-gson/1.20.0/google-api-client-gson-1.20.0.jar
Required by:
:Hotels:unspecified
> Could not find com.google.apis:google-api-services-gmail:v1-rev29-1.20.0.
Searched in the following locations:
file:/home/sanctus/adt/sdk/extras/android/m2repository/com/google/apis/google-api-services-gmail/v1-rev29-1.20.0/google-api-services-gmail-v1-rev29-1.20.0.pom
file:/home/sanctus/adt/sdk/extras/android/m2repository/com/google/apis/google-api-services-gmail/v1-rev29-1.20.0/google-api-services-gmail-v1-rev29-1.20.0.jar
file:/home/sanctus/adt/sdk/extras/google/m2repository/com/google/apis/google-api-services-gmail/v1-rev29-1.20.0/google-api-services-gmail-v1-rev29-1.20.0.pom
file:/home/sanctus/adt/sdk/extras/google/m2repository/com/google/apis/google-api-services-gmail/v1-rev29-1.20.0/google-api-services-gmail-v1-rev29-1.20.0.jar
Required by:
:Hotels:unspecified

我将eclipse与adt插件一起使用,并且从命令行使用gradle

最佳答案

您必须在build.gradle中添加此部分

repositories {
mavenCentral()
}

这些库位于Central Maven中:
com.google.api-client:google-api-client:1.20.0.
com.google.api-client:google-api-client-android:1.20.0
com.google.api-client:google-api-client-gson:1.20.0

关于这个图书馆,我不知道在哪里。
com.google.apis:google-api-services-gmail:v1-rev29-1.20.0

我也建议您使用以下版本:
  • Android Studio 1.2.x
  • classpath 'com.android.tools.build:gradle:1.2.3'
  • gradle 2.4
  • 关于android - Gradle无法解决所有依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30823929/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com