【问题标题】:Not able to resolve com.github.chrisbanes:PhotoView:1.3.1无法解析 com.github.chrisbanes:PhotoView:1.3.1
【发布时间】:2025-12-04 03:00:02
【问题描述】:

我正在使用来自这个库 com.github.chrisbanes:PhotoView:1.3.1 的 photoview。但是我的 Gradle 没有同步。

我已经在这个 url 上添加了来自 Gradle Dependancy 的 Maven 代码:https://github.com/chrisbanes/PhotoView

【问题讨论】:

  • @ρяσѕρєяK 我已经这样做了,但错误即将到来
  • 你添加maven { url "https://jitpack.io" }了吗?
  • 确保你添加到你的根 gradle 。类路径 'com.github.dcendents:android-maven-gradle-plugin:1.5'
  • @chris:像 Gradle 和 Maven 这样的名称不是代码,因此不需要格式化。初始上限很好。

标签: android android-gradle-plugin android-photoview


【解决方案1】:

我遇到了这个问题,并通过在 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 块中添加了存储库,它对他有用。

【讨论】:

    【解决方案2】:

    这个库的最新版本是2.0.0 [截至18 Mar 2017](不是1.3.1)见releases

    在你的模块级别使用这个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
    

    【讨论】:

      【解决方案3】:

      在照片浏览后添加“图书馆” 例如:实现“com.github.chrisbanes.photoview:library:1.2.4”

      https://bintray.com/bintray/jcenter/com.github.chrisbanes.photoview:library#statistics

      【讨论】:

        【解决方案4】:

        这是我的答案,经过一些尝试解决了!

        在您的 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'
        

        这应该有效,希望它会有所帮助。

        【讨论】:

          【解决方案5】:

          在你的 gradle.settings 中添加:

          dependencyResolutionManagement {
              repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
              repositories {
                  maven { url "https://jitpack.io" }
              }
          }
          

          【讨论】:

            【解决方案6】:

            粘贴这个:

            maven { url "https://www.jitpack.io" }
            

            settings.gradle 中,并粘贴此依赖项:

            implementation'com.github.chrisbanes:PhotoView:latest.release.here'
            

            build.gradle中。

            settings.gradle

            【讨论】:

              最近更新 更多