【问题标题】:Could not resolve all files for configuration ':react-native-image-picker:classpath'无法解析配置“:react-native-image-picker:classpath”的所有文件
【发布时间】:2019-05-11 22:04:04
【问题描述】:

我一个星期没碰我的项目,但是当我回来在android模拟器上运行项目时突然出现这个错误

* What went wrong:
A problem occurred configuring project ':react-native-image-picker'.
> Could not resolve all files for configuration ':react-native-image-picker:classpath'.
> Could not find any matches for com.android.tools.build:gradle:2.2.+ as no versions of com.android.tools.build:gradle are available.
 Searched in the following locations:
     https://jcenter.bintray.com/com/android/tools/build/gradle/maven-metadata.xml
     https://jcenter.bintray.com/com/android/tools/build/gradle/
 Required by:
     project :react-native-image-picker

我的 build.gradle

buildscript {
repositories {
    jcenter()
    google()
    mavenLocal()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'

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

allprojects {
repositories {
    mavenLocal()
    jcenter()
    maven { url "https://jitpack.io" }
    maven { url "https://maven.google.com" }
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
}
}

我在 stackoverflow 上搜索了一段时间,但找不到解决方案。任何帮助表示赞赏。

【问题讨论】:

  • 您正在查看错误的 gradle 文件。寻找具有2.2.+ 的那个。也许在app 文件夹下查看。如果找到,请将其更改为2.1.2。由于某种原因,我今天遇到了同样的问题。

标签: android android-studio react-native


【解决方案1】:

google() 移到jcenter() 上方并为allProjects 部分执行此操作也解决了我同样的问题。

【讨论】:

    【解决方案2】:

    查看此答案,它应该可以帮助您解决问题: https://stackoverflow.com/a/53692168/3104599

    由于链接不够,我将在此处复制粘贴答案。知道答案不是我自己的,我只是引用:

    这是我的修复,我没有 fork repos 只是使用了这个解决方法:添加 这是你的 build.gradle 文件,settings.gradle 文件的兄弟

    subprojects { project ->
    def name = project.name
    if (name.contains('module name, e.g. react-native-blur')
            || name.contains('other module name, e.g. react-native-image-picker')) {
        buildscript {
            repositories {
                maven { url "https://dl.bintray.com/android/android-tools/"  }
            }
        }
    } }
    

    【讨论】:

      【解决方案3】:

      检查这个:https://github.com/react-native-community/react-native-image-picker/issues/999#issuecomment-445465847

      我有同样的错误,我用这个答案纠正了它。

      您只需使用与android/build.gradle 相同的“类路径”来编辑node_modules/react-native-image-picker/android/build.gradle 的“类路径”。

      希望对你有用。

      【讨论】:

        【解决方案4】:

        升级到最新版本0.27.2,问题已修复

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多