[英]Can not build android app react-native-vector-icons:releaseCompileClasspath
[英]React-native app build problem after install react-native-vector-icons
安裝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”,
有人可以幫我嗎?
最好的選擇是降級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
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
這些步驟對我有用
我遇到了相同的錯誤,以下步驟對我有用:
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中添加了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。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.