在安装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.
已安装的版本: “ react”:“ 16.3.1”, “ react-native”:“ 0.55.4”, “ react-native-elements”:“ ^ 0.19.1”, “ react-native-vector-icons”:“ ^ 6.0.2”,
有人可以帮我吗?
答案 0 :(得分:2)
您最好的选择是降级vector-icons
版本或升级react-native + react
版本。
另一种选择是在android项目中手动更新gradle
和gradle-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
答案 1 :(得分:0)
yarn install
yarn add react-native-vector-icons
react-link native command react-native-vector-icons
reage-nactive run- android 7 then react-native start --reset-cache
这些步骤对我有用
答案 2 :(得分:0)
我有相同的错误,以下步骤对我有用:
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,您的可以不同)。
在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。