I am working on an old React Native app and want to upgrade RN version from version ^0.64.2 to 0.70.1. After using command npx react-native upgrade, there are changes in number version of dependencies. I also edit build.gradle in andriod\app folder as instructed in this document:
project.ext.react = [
enableHermes: true // clean and rebuild if changing
]
...
dependencies {
...
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
...
}
After that, I run command ./gradlew clean in android folder and run npx react native run-android. Then this error shows up:
BUILD FAILED in 9s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform hermes-debug.aar to match attributes {artifactType=android-aar-metadata}.
> Execution failed for JetifyTransform: D:\{ProjectFolder}\node_modules\hermes-engine\android\hermes-debug.aar.
> Transform's input file does not exist: D:\{ProjectFolder}\node_modules\hermes-engine\android\hermes-debug.aar. (See https://issuetracker.google.com/issues/158753935)
After taking a while, I also found out that there is no hermes-engine folder inside node_modules folder but still have no clue what to do.
Here is my package.json:
{
"name": "MyApp",
"version": "1.0.0",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@notifee/react-native": "^3.0.4",
"@react-native-async-storage/async-storage": "^1.17.10",
"@react-native-community/art": "^1.2.0",
"@react-native-community/datetimepicker": "^3.5.2",
"@react-native-firebase/app": "^12.9.0",
"@react-native-firebase/messaging": "^12.9.0",
"@react-navigation/material-top-tabs": "^6.2.1",
"@react-navigation/native": "^6.0.1",
"@react-navigation/stack": "^6.2.1",
"axios": "^0.24.0",
"fbjs": "^3.0.4",
"jest": "^26.6.3",
"jwt-decode": "^3.1.2",
"moment": "^2.29.3",
"moment-timezone": "^0.5.34",
"prop-types": "^15.8.1",
"react": "18.1.0",
"react-native": "0.70.1",
"react-native-biometrics": "^2.1.4",
"react-native-camera": "^3.35.0",
"react-native-chart-kit": "^6.12.0",
"react-native-elements": "^2.0.4",
"react-native-file-viewer": "^2.1.1",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-image-crop-picker": "^0.32.2",
"react-native-modal": "^11.5.6",
"react-native-pager-view": "^5.4.24",
"react-native-pdf": "^6.2.0",
"react-native-picker-select": "^8.0.0",
"react-native-pie-chart": "^2.0.2",
"react-native-render-html": "^6.3.4",
"react-native-safe-area-context": "^3.0.2",
"react-native-screens": "^3.13.1",
"react-native-simple-toast": "^1.1.2",
"react-native-svg": "^12.1.1",
"react-native-swipe-list-view": "^3.2.9",
"react-native-tab-view": "^3.1.1",
"react-native-vector-icons": "^7.0.0",
"react-navigation": "^4.4.0",
"react-query": "^3.34.2",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"toggle-switch-react-native": "^3.3.0"
},
"devDependencies": {
"@react-native-community/eslint-config": "^2.0.0",
"babel-plugin-root-import": "^6.5.0",
"eslint": "^7.14.0",
"react-test-renderer": "^17.0.1"
},
"jest": {
"preset": "react-native"
}
}
Thanks
project.ext.react = [
enableHermes: true // clean and rebuild if changing
]
...
dependencies {
...
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
...
}
After that, I run command ./gradlew clean in android folder and run npx react native run-android. Then this error shows up:
BUILD FAILED in 9s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform hermes-debug.aar to match attributes {artifactType=android-aar-metadata}.
> Execution failed for JetifyTransform: D:\{ProjectFolder}\node_modules\hermes-engine\android\hermes-debug.aar.
> Transform's input file does not exist: D:\{ProjectFolder}\node_modules\hermes-engine\android\hermes-debug.aar. (See https://issuetracker.google.com/issues/158753935)
After taking a while, I also found out that there is no hermes-engine folder inside node_modules folder but still have no clue what to do.
Here is my package.json:
{
"name": "MyApp",
"version": "1.0.0",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@notifee/react-native": "^3.0.4",
"@react-native-async-storage/async-storage": "^1.17.10",
"@react-native-community/art": "^1.2.0",
"@react-native-community/datetimepicker": "^3.5.2",
"@react-native-firebase/app": "^12.9.0",
"@react-native-firebase/messaging": "^12.9.0",
"@react-navigation/material-top-tabs": "^6.2.1",
"@react-navigation/native": "^6.0.1",
"@react-navigation/stack": "^6.2.1",
"axios": "^0.24.0",
"fbjs": "^3.0.4",
"jest": "^26.6.3",
"jwt-decode": "^3.1.2",
"moment": "^2.29.3",
"moment-timezone": "^0.5.34",
"prop-types": "^15.8.1",
"react": "18.1.0",
"react-native": "0.70.1",
"react-native-biometrics": "^2.1.4",
"react-native-camera": "^3.35.0",
"react-native-chart-kit": "^6.12.0",
"react-native-elements": "^2.0.4",
"react-native-file-viewer": "^2.1.1",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-image-crop-picker": "^0.32.2",
"react-native-modal": "^11.5.6",
"react-native-pager-view": "^5.4.24",
"react-native-pdf": "^6.2.0",
"react-native-picker-select": "^8.0.0",
"react-native-pie-chart": "^2.0.2",
"react-native-render-html": "^6.3.4",
"react-native-safe-area-context": "^3.0.2",
"react-native-screens": "^3.13.1",
"react-native-simple-toast": "^1.1.2",
"react-native-svg": "^12.1.1",
"react-native-swipe-list-view": "^3.2.9",
"react-native-tab-view": "^3.1.1",
"react-native-vector-icons": "^7.0.0",
"react-navigation": "^4.4.0",
"react-query": "^3.34.2",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"toggle-switch-react-native": "^3.3.0"
},
"devDependencies": {
"@react-native-community/eslint-config": "^2.0.0",
"babel-plugin-root-import": "^6.5.0",
"eslint": "^7.14.0",
"react-test-renderer": "^17.0.1"
},
"jest": {
"preset": "react-native"
}
}
Thanks