【问题标题】:React-native app build problem after install react-native-vector-icons安装 react-native-vector-icons 后的 React-native 应用程序构建问题
【发布时间】:2018-10-25 22:08:47
【问题描述】:

安装 react-native-vector-icons 并尝试在模拟器中构建 android 应用程序后,我在 react-native 项目中遇到问题。我在 Windows 上工作。 我按照手册中的说明安装了库并链接了它,但我认为我有依赖问题。

C:\react-native run-android
Scanning folders for symlinks in C:\Users\user\Source\reactnative\myapp\node_modules (43ms)
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat installDebug)...

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\user\Source\reactnative\myapp\node_modules\react-native-vector-icons\android\build.gradle' line: 4

* What went wrong:
A problem occurred evaluating project ':react-native-vector-icons'.
> Could not find method google() for arguments [] on repository container.

已安装版本: “反应”:“16.3.1”, “反应原生”:“0.55.4”, “反应原生元素”:“^0.19.1”, "react-native-vector-icons": "^6.0.2",

有人可以帮帮我吗?

【问题讨论】:

标签: android windows react-native react-native-android android-icons


【解决方案1】:

您最好的选择是降级vector-icons 版本或升级react-native + react 版本。

另一种选择是在 android 项目中手动更新您的 gradlegradle-wrapper 版本。

所以更新顶层gradle文件中的gradle版本:

通常位于:project_name/android/build.gradle

改为:

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

还有 gradle-wrapper:

通常位于:project_name/android/gradle/wrapper/gradle-wrapper.properties

改为:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

【讨论】:

  • 感谢您的回答。在Win10上gradle和react-native的版本出现了几次问题后,我搞定了。
【解决方案2】:

我遇到了同样的错误,以下步骤对我有用:

1.修改android/build/gradle中的代码

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

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

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

在上面的代码中,在 buildscript 和 allprojects 中添加了 google() 和 classpath gradle 版本被 ..\node_modules\react-native-vector-icons\android\build.gradle 中的 classpath 的 gradle 版本替换(我的是 3.3.1,你的可以不同)。

  1. 在android/gradle/wrapper/gradle-wrapper.properties中,修改distributionUrl:

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
    

上述库的版本是4.10.1,gradle 3.3.1版本需要的上述库的最低版本是4.10.1,所以我在我的项目中安装了gradle-4.10.1-all.zip。

【讨论】:

    【解决方案3】:
    1. 卸载矢量图标(删除wire-react-vector-icons-native)
    2. 删除文件夹 node_modules
    3. 然后yarn install
    4. 键入此命令yarn add react-native-vector-icons
    5. 然后这个react-link native command react-native-vector-icons
    6. 然后这个命令reage-nactive run- android 7 then react-native start --reset-cache

    这些步骤对我有用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-05
      • 1970-01-01
      • 2018-02-18
      相关资源
      最近更新 更多