找不到 com.squareup.picasso:picasso:2.5.2

Could not find com.squareup.picasso:picasso:2.5.2

我添加了 picasso 依赖项,但似乎没有用。我尝试更改版本。但是还是没用。

这是我的 build.gradle(模块)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'

    defaultConfig {
        applicationId "bhouse.travellist_starterproject"
        minSdkVersion 21
        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:23.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support:cardview-v7:23.4.0'
    compile 'com.android.support:palette-v7:23.4.0'
    compile 'com.squareup.picasso:picasso:2.5.1'

}

这是我的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:2.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

错误说:

Error:(27, 13) Failed to resolve: com.squareup.picasso:picasso:2.5.1 Show in File
Show in Project Structure dialog

欢迎任何帮助。

您需要添加可以从中下载 Picasso 的 Maven 存储库。您可以通过将此添加到您的应用程序模块的 build.gradle 文件中来做到这一点:

repositories {
    jcenter()
}

一个好地方就在你的 dependencies {} 街区之前。

您需要在主 build.gradle 末尾添加一个部分 allprojects 来定义项目模块的存储库:

allprojects {
    repositories {
        jcenter()
    }
}

这将导致以下结果 build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

根据他们的 Github,您必须使用 MavenCentral 来获取他们的库,因此将其添加到您的 build.gradle(app) 文件中:

repositories {
    mavenCentral()
}

重新同步并重试。

就我而言,我只是在 gradle.properties 设置中设置了 https

systemProp.https.proxyHost=some.proxy.adress.com

systemProp.https.proxyPort=8080

所以在我的例子中,gradle.properties 将是:

systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=8080

当我使用该应用程序时开始,只有一个构建(模块)而没有构建(应用程序)。

添加Picasso库后出现Error: (line, column) Failed to resolve: com.squareup.picasso: Picasso: 2.5.2 Show in File ||在项目结构对话框中显示

以及 glide 库

并且解决方案如其所说 (DenisGL) 添加了所有项目如下:

allprojects {
    repositories {
        jcenter ()
    }
}