android - Gradle 找不到库

标签 android android-studio gradle

我正在使用 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/

相关文章:

android - 您应该通过 DependencyResolution 手动设置相同的版本

gradle - 使用Gradle将文件夹复制到耳朵的根部

android - 添加 avd 时出错

Android Studio 看起来不正常

android - ViewPagerIndicator 与 Gradle 和 Android Studio 的依赖关系

java - 无法在 IntelliJ 中的 Jax-RS 项目上配置 gradle

android - 我应该如何处理 "implementation method not found"错误?

android - OAuth同意屏幕是空白的,加载图标在android应用程序中一直旋转,

android - 功能挂起UI

android - 从 Android Studio 运行 Kotlin Koans 测试