使用较新版本的Android Studio,我们已经宣传您可以将编译语句添加到build.gradle文件中,以供Maven Central和Android Studio上可用的第三方库自动下载相应的依赖项。但是,当我尝试添加其中一个库时,我无法成功完成Gradle Sync。这是项目的build.gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.appsbysynapps.helloname"
minSdkVersion 14
targetSdkVersion 21
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:21.0.3'
compile 'com.larswerkman:HoloColorPicker:1.5'
}
这是模块的build.gradle
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
以下是Gradle发出的错误
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve com.larswerkman:HoloColorPicker:1.5.
Required by:
HelloName:app:unspecified
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
对于我尝试添加的任何第三方库,我遇到了同样的问题。这也是在Android Studio 1.1.0中创建的全新项目,并且禁用了离线模式。对于发生了什么的任何想法?