【问题标题】:Could not find any matches for com.android.tools.build:gradle:2.3.+找不到 com.android.tools.build:gradle:2.3.+ 的任何匹配项
【发布时间】:2019-05-12 03:19:10
【问题描述】:

当我尝试通过 react-native run-android 构建我的应用程序时遇到此错误。昨天还好好的,今天突然出现这个错误。

我已经检查了 react native 矢量图标,它看起来不错,这也适用于 iOS。

这是错误:

   * What went wrong:
A problem occurred configuring project ':react-native-vector-icons'.
> Could not resolve all files for configuration ':react-native-vector-icons:classpath'.
   > Could not find any matches for com.android.tools.build:gradle:2.3.+ 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-vector-icons

这是我的 gradle 文件:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        google()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:3.2.0'
        classpath 'io.fabric.tools:gradle:1.+'

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

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

ext {
    buildToolsVersion = "26.0.1"
    minSdkVersion = 16
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
}

subprojects {

 project.configurations.all {
    resolutionStrategy.eachDependency { details ->
       if (details.requested.group == 'com.android.support'
              && !details.requested.name.contains('multidex') ) {
           details.useVersion "26.0.1"
        }
     }
  }

  afterEvaluate {project ->
      if (project.hasProperty("android")) {
          android {
              compileSdkVersion rootProject.ext.compileSdkVersion
              buildToolsVersion '26.0.1'
              defaultConfig {
                  targetSdkVersion rootProject.ext.targetSdkVersion
              }
          }
      }
  }
}

我在这里错过了什么?

【问题讨论】:

    标签: java android maven gradle build


    【解决方案1】:

    我实际上已经通过更新 react-native-vector-icons 解决了这个问题。

    我使用的方法描述HERE

    【讨论】:

      【解决方案2】:

      尝试将此添加到您的build.gradle 文件中。

      subprojects {
          if (project.name.contains('react-native-vector-icons')) {
              buildscript {
                  repositories {
                      jcenter()
                      maven { url "https://dl.bintray.com/android/android-tools/"  }
                  }
              }
          }
      }
      

      【讨论】:

        【解决方案3】:

        尝试将“react-native-vector-icons”包更新到最新版本(6.1.0)。

        【讨论】:

          【解决方案4】:

          基于此link

          安卓许可证。也许试试 $ANDROID_HOME/tools/bin/sdkmanager "build-tools;26.0.1" "platforms;android-26" 看看是否有帮助。

          这张图片可以帮助你

          建议你更新buildToolsVersionsupportLibVersion

          【讨论】:

          • 谢谢!现在工作正常!所以我更新了构建工具版本并更新了 react-native-vector-icons,现在运行良好
          猜你喜欢
          • 2019-05-11
          • 2019-05-11
          • 2019-05-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-04-16
          • 2023-01-30
          • 1970-01-01
          相关资源
          最近更新 更多