I was runing a project(contacts from) "fullstack react native" book in react native. but I have a problem with react-native-vector-icons.
when I run react-native run-android
it showed me bellow error:
D:\android_Project\Vitel\React_Nativ\test\ZContacts>react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using
"--no-jetifier" flag.
Jetifier found 874 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-vector-icons'.
> Could not resolve all artifacts for configuration ':react-native-vector-icons:
classpath'.
> Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2-p
roto/0.3.1/aapt2-proto-0.3.1.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 48s
error Failed to install the app. Make sure you have the Android development envi
ronment set up: https://facebook.github.io/react-native/docs/getting-started.htm
l#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8
081
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-vector-icons'.
> Could not resolve all artifacts for configuration ':react-native-vector-icons:
classpath'.
> Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2-p
roto/0.3.1/aapt2-proto-0.3.1.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 48s
at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (D:\android_Project\Vitel\React_Nativ\test\ZContacts\node
_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\
runOnAllDevices.js:94:39)
at buildAndRun (D:\android_Project\Vitel\React_Nativ\test\ZContacts\node_mod
ules\@react-native-community\cli-platform-android\build\commands\runAndroid\inde
x.js:158:41)
at then.result (D:\android_Project\Vitel\React_Nativ\test\ZContacts\node_mod
ules\@react-native-community\cli-platform-android\build\commands\runAndroid\inde
x.js:125:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
my Build.gradle is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
}
repositories {
google()
jcenter()
}
dependencies {
classpath('com.android.tools.build:gradle:3.5.0')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
and app/build.gradle is:
apply plugin: "com.android.application"
import com.android.build.OutputFile
def enableHermes = project.ext.react.get("enableHermes", false);
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.zcantacts"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
again i tried to run a new simple project so i do bellow commands:
I tried a new simple project with this commads:
>react-native init testicons
>cd testicons
change build.gradle (change classpath("com.android.tools.build:gradle:3.4.2") to classpath("com.android.tools.build:gradle:3.5.0")
)
then app run with react-native run-android (without import from react-native-vector-icons)
and run these commands:
>npm install react-native-vector-icons
and
>react-native link react-native-vector-icons
i changed app.js:
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React from 'react';
import {View,} from 'react-native';
import { MaterialIcons } from 'react-native-vector-icons';
const getTabBarIcon = icon => ({ tintColor }) => (
<MaterialIcons name={icon} size={26} style={{ color: tintColor }} />
);
const App: () => React$Node = () => {return (<><View >{getTabBarIcon('list')}</View></>);};
export default App;
but when I run bellow cammand i had same error as before!
react-native run-android
that error was:
D:\android_Project\Vitel\React_Nativ\testicons>react-native run-android
error React Native CLI uses autolinking for native dependencies, but the followi
ng modules are linked manually:
- react-native-vector-icons (to unlink run: "react-native unlink react-native-
vector-icons")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or
above. Going forward, you can unlink this dependency via "react-native unlink <d
ependency>" and it will be included in your app automatically. If a library isn'
t compatible with autolinking, disregard this message and notify the library mai
ntainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/
master/docs/autolinking.md
info Running jetifier to migrate libraries to AndroidX. You can disable it using
"--no-jetifier" flag.
Jetifier found 867 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-vector-icons'.
> Could not resolve all artifacts for configuration ':react-native-vector-icons:
classpath'.
> Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2-p
roto/0.3.1/aapt2-proto-0.3.1.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 28s
error Failed to install the app. Make sure you have the Android development envi
ronment set up: https://facebook.github.io/react-native/docs/getting-started.htm
l#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8
081
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':react-native-vector-icons'.
> Could not resolve all artifacts for configuration ':react-native-vector-icons:
classpath'.
> Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2-p
roto/0.3.1/aapt2-proto-0.3.1.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 28s
at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (D:\android_Project\Vitel\React_Nativ\testicons\node_modu
les\@react-native-community\cli-platform-android\build\commands\runAndroid\runOn
AllDevices.js:94:39)
at buildAndRun (D:\android_Project\Vitel\React_Nativ\testicons\node_modules\
@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:
158:41)
at then.result (D:\android_Project\Vitel\React_Nativ\testicons\node_modules\
@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:
125:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
can you help me? what is problem and how can I resolve it?