I have a problem in a react-native project after install react-native-vector-icons and try to build android app in the emulator. I'm working on 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",
Can somebody help me?
Your best option is to either downgrade the vector-icons
version or upgrade react-native + react
versions.
Another option is to manually update your gradle
and gradle-wrapper
versions in the android project.
So update the gradle version in the top-level gradle file:
Usually located here: project_name/android/build.gradle
Change to:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
And also the gradle-wrapper:
Usually located here: 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 add react-native-vector-icons
react-link native command react-native-vector-icons
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.
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).
in android/gradle/wrapper/gradle-wrapper.properties, modify the 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.