[英]React-native app build problem after install react-native-vector-icons
I have a problem in a react-native project after install react-native-vector-icons and try to build android app in the emulator. 安装react-native-vector-icons并尝试在模拟器中构建android应用后,我在react-native项目中遇到问题。 I'm working on Windows. 我在Windows上工作。 I installed the library and linked it as said in the manual, but I think I have a dependency problem. 我安装了该库并按照手册中的说明进行了链接,但是我认为我遇到了依赖问题。
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.
Installed versions: "react": "16.3.1", "react-native": "0.55.4", "react-native-elements": "^0.19.1", "react-native-vector-icons": "^6.0.2", 安装的版本:“ react”:“ 16.3.1”,“ react-native”:“ 0.55.4”,“ react-native-elements”:“ ^ 0.19.1”,“ react-native-vector-icons”: “ ^ 6.0.2”,
Can somebody help me? 有人可以帮我吗?
Your best option is to either downgrade the vector-icons
version or upgrade react-native + react
versions. 最好的选择是降级vector-icons
版本或升级react-native + react
版本。
Another option is to manually update your gradle
and gradle-wrapper
versions in the android project. 另一种选择是在android项目中手动更新gradle
和gradle-wrapper
版本。
So update the gradle version in the top-level gradle file: 因此,请在顶级gradle文件中更新gradle版本:
Usually located here: project_name/android/build.gradle
通常位于此处: project_name/android/build.gradle
Change to: 改成:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
And also the gradle-wrapper: 还有gradle-wrapper:
Usually located here: project_name/android/gradle/wrapper/gradle-wrapper.properties
通常位于这里: project_name/android/gradle/wrapper/gradle-wrapper.properties
Change to: 改成:
distributionUrl=https\\://services.gradle.org/distributions/gradle-4.10.2-all.zip
yarn install
然后yarn install
yarn add react-native-vector-icons
键入此命令yarn add react-native-vector-icons
react-link native command react-native-vector-icons
然后这个react-link native command react-native-vector-icons
reage-nactive run- android 7 then react-native start --reset-cache
然后此命令reage-nactive run- android 7 then react-native start --reset-cache
These steps worked for me 这些步骤对我有用
I had the same errors, the following steps worked for me: 我遇到了相同的错误,以下步骤对我有用:
1.change the code in android/build/gradle. 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()
}
}
In the above code, google() is added in buildscript and allprojects and classpath gradle version is replaced by the gradle version of classpath in ..\\node_modules\\react-native-vector-icons\\android\\build.gradle (mine is 3.3.1, yours can be different). 在上面的代码中,在buildscript中添加了google(),所有项目和classpath gradle版本都由.. \\ node_modules \\ react-native-vector-icons \\ android \\ build.gradle中的 classpath的gradle版本代替(我的是3.3。 1,您的可以不同)。
in android/gradle/wrapper/gradle-wrapper.properties, modify the distributionUrl: 在android / gradle / wrapper / gradle-wrapper.properties中,修改distributionUrl:
distributionUrl=https\\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Version of the above library is 4.10.1, The minimum version of the above library required by gradle version 3.3.1 is 4.10.1, so I installed gradle-4.10.1-all.zip in my project. 上面的库的版本是4.10.1,gradle版本3.3.1要求的上面的库的最低版本是4.10.1,所以我在项目中安装了gradle-4.10.1-all.zip。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.