我正在使用 android studio。具有以下依赖关系。 Gradle 无法找到第三方库 volley 和 square,但找到了 appcompat:
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.mcxiaoke.volley:library:1.0.+@aar'
compile 'com.squareup.phrase:phrase:1.0.3'
.
Error:Failed to find: com.mcxiaoke.volley:library:1.0.+
我已经更新了 Android SDK Manager 工具和 Extras,包括支持库,但仍然没有运气。我已经尝试过 jcenter() 和 mavenCentral()。有人可以帮忙吗?
build.gradle
:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
dependencies{
}
}
app/build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.tap"
minSdkVersion 8
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.mcxiaoke.volley:library:1.0.+@aar'
compile 'com.squareup.phrase:phrase:1.0.3'
}
settings.gradle
:
include ':app'
最佳答案
您需要从
更改您的 volley 依赖项(在项目应用程序结构级别的 build.gradle 中)compile 'com.mcxiaoke.volley:library:1.0.+@aar'
至
compile 'com.mcxiaoke.volley:library:1.0.+'
& 在存储库部分中包含 mavenCentral()。 在您的 app/build.gradle 中,在发布部分之后的存储库部分中添加 mavenCentral() 。
Note - Google doesn’t provide a build of Volley for Gradle but there are mirrored copies of Volley published for use in Gradle.
参见Unofficial mirror for android-volley library here .
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
repositories {
mavenCentral()
}
}
并将依赖项部分更改为类似:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.squareup.phrase:phrase:1.0.3'
}
关于android - Gradle 找不到库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29626177/