无法解决com.github.chrisbanes:PhotoView:1.3.1问题。

7
我正在使用这个库中的photoview: com.github.chrisbanes:PhotoView:1.3.1,但我的Gradle无法同步。 error gradle file 我已经按照此URL上Gradle Dependency中的Maven代码进行了添加:https://github.com/chrisbanes/PhotoView

请查看此处Gradle依赖项 - ρяσѕρєя K
@ρяσѕρєяK 我已经做了这个,但还是出现错误。 - Raj Suvariya
你是否添加了 maven { url "https://jitpack.io" }? - ρяσѕρєя K
请确保在您的根Gradle中添加了以下内容:classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' - QuokMoon
@chris:像Gradle和Maven这样的名称不是代码,因此不需要进行格式化。首字母大写即可。 - halfer
@QuokMoon,我已添加classpath,但仍然出现同样的错误。 - Raj Suvariya
7个回答

14

我遇到了这个问题,并通过在buildscript中添加仓库来解决它。这里是我的 build.gradle 文件(不是模块文件,而是项目文件):

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我不知道为什么需要这样做,因为我的一个朋友只是在 allprojects 块中添加了该存储库,它对他有效。


3
在你的 gradle.settings 中加入以下内容:
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        maven { url "https://jitpack.io" }
    }
}

2
把这个粘贴进去:
maven { url "https://www.jitpack.io" }

settings.gradle 文件中,粘贴以下依赖项:
implementation'com.github.chrisbanes:PhotoView:latest.release.here'

build.gradle 中。

settings.gradle


2
这个库的最新版本是2.0.0[截至2017年3月18日](而不是1.3.1),请查看发布页面
在您的模块级build.gradle中使用此代码:
implementation 'com.github.chrisbanes:PhotoView:2.0.0'

测试通过(这里是 gradle/jitpack 找到的):

Download https://jitpack.io/com/github/chrisbanes/PhotoView/2.0.0/PhotoView-2.0.0.pom
Download https://jitpack.io/com/github/chrisbanes/PhotoView/2.0.0/PhotoView-2.0.0.aar

0

0

这是我的答案,经过多次尝试解决了!

在你的 build.gradle 文件中,应该有最后两行。

allprojects {
    repositories {
        google()
        jcenter()

        // for photo view
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com" }
    }
}

然后添加最新版本。

// photo view
implementation 'com.github.chrisbanes:PhotoView:2.3.0'

这应该可以运行,希望能帮到你。


-1

在settings.gradle中添加:

dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            jcenter() // Warning: this repository is going to shut down soon
            maven { url "https://jitpack.io" }
        }
    }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接