配置项目':app'时发生问题

时间:2018-12-11 05:15:21

标签: react-native

尝试运行本机运行android时出现错误。我不知道为什么会收到此错误。

RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

android \ build.gradle如下。

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
> A problem occurred configuring project ':react-native-vector-icons'.
  > Could not resolve all dependencies 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.

渐变版本:3.3, 插件:2.2.3

2 个答案:

答案 0 :(得分:0)

  1. 升级package.json中的react-native-vector-icons: "^6.0.2"
  2. 然后运行npm i react-native-vector-icons
  3. 最后一步,cd android && ./gradlew clean

答案 1 :(得分:0)

更改依赖项:

dependencies { implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}" }

收件人:

dependencies { compile "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}" }

还将更改构建脚本依赖项以使用:classpath 'com.android.tools.build:gradle:2.2.3'maven { url "https://dl.bintray.com/android/android-tools/" }代替google()

所以您的../node_modules/react-native-vector-icons/android/build.gradle应该如下所示:

buildscript {
  repositories {
    maven { url "https://dl.bintray.com/android/android-tools/" }
    jcenter()
  }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    }
}

apply plugin: 'com.android.library'

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}


android {
  compileSdkVersion safeExtGet('compileSdkVersion', 26)
  buildToolsVersion safeExtGet('buildToolsVersion', '26.0.3')

  defaultConfig {
    minSdkVersion safeExtGet('minSdkVersion', 16)
    targetSdkVersion safeExtGet('targetSdkVersion', 26)
    versionCode 1
    versionName "1.0"
  }
  lintOptions {
    abortOnError false
  }
}

repositories {
  mavenCentral()
}

dependencies {
  compile "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
}