Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
BUILD FAILED in 19s
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 react-native-reanimated-65-jsc.aar (project :react-native-reanimated) to match attributes {artifactType=android-aar-metadata}.
> Execution failed for JetifyTransform: C:\Users\Rahul\Desktop\lcorn\rb\node_modules\react-native-reanimated\android\react-native-reanimated-65-jsc.aar. > Transform's input file does not exist: C:\Users\Rahul\Desktop\lcorn\rb\node_modules\react-native-reanimated\android\react-native-reanimated-65-jsc.aar. (See https://issuetracker.google.com/issues/158753935)
* 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 19s
at makeError (C:\Users\Rahul\Desktop\lcorn\rb\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at C:\Users\Rahul\Desktop\lcorn\rb\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at async runOnAllDevices (C:\Users\Rahul\Desktop\lcorn\rb\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:106:5)
at async Command.handleAction (C:\Users\Rahul\Desktop\lcorn\rb\node_modules\#react-native-community\cli\build\index.js:186:9)
info Run CLI with --verbose flag for more details.
PS C:\Users\Rahul\Desktop\lcorn\rb>
"react": "17.0.2",
"react-native": "0.65.0",
I don't think react-native-reanimated supports Hermes on Android with React Native 0.65.0. I was able to fix it removing react-native-reanimated because I don't use it. Maybe you can remove it or disable Hermes.
Installing react-native-reanimated#2.3.0-alpha.2 also fixes it.
This issue has been fixed in the latest build (alpha release).
yarn add react-native-reanimated#2.3.0-alpha.3
Here is the list of version releases: https://www.npmjs.com/package/react-native-reanimated?activeTab=versions
New upgrade is not yet released react-native-reanimated-65-jsc.aar.
After the installation of the package, navigate to node_modules folder and search for react-native-reanimated. Navigate to android and see if anything ending with 65 is visible.. else it wont work.
Alternate options, [with downgrade to 0.64.2] it does work... but the version gets reset after the build.
This is one of the key file to be updated node_modules> react-native-reanimated > android > build.gradle to make it work
Follow the instructions as given in the site
https://docs.swmansion.com/react-native-reanimated/docs/installation/
set the following too enableHermes: true .. No harm in setting it
Now follow these steps
in your android > gradle > wrapper>gradle-wrapper.properties change
distributionUrl=https://services.gradle.org/distributions/gradle-6.8-all.zip
android > build. gradle. Change these two items; as class path goes set with 6.8-all goes with 4.2.2
uninstall react-native .65 and run for 0.64.2
delete your package-lock.json
watchman watch-del-all
Delete node_modules
run yarn install
yarn start --reset-cache
rm -rf /tmp/metro-*
[This can be an optional step..as RN .64 is set]
Now go back to the node_modules folder and search for the 'react-native-reanimated' folder and change this
artifacts.add("default", file("react-native-reanimated-${minor}.aar"))
to
artifacts.add("default", file("react-native-reanimated-64.aar"))
Now start with your build.. you should not see the issue reported.
. Update
Just install react-native-reanimated#2.3.0-alpha.3 or any updated version.
It will fix this issue.
I have upgraded my react native vers to 0.65.1 and had this problem too. Try to make:
npm uninstall react-native-reanimated
npm i react-native-reanimated
cd android
./gradlew wrapper
cd ..
npx react-native run-android
If you don't want to use alpha version of the library, you may install react-native-reanimated#2.2.1 too for React Native 0.65
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Getting the following message when I init a new project and then launch the Xcode emulator:
React-Native Version Mismatch
Javascript Version 0.50.1
Native version: 0.50.0
Make sure you have rebuilt the native code. ...
Does anyone know what is going on here and can help me?
This is what I've done with it:
Close all terminals and run build again.
You may forget to close nodejs terminal from another project, and they happen to have installed different react version.
So the code fetches from nodejs server conflicts with the native one.
In case you created your react-native app using create-react-native-app. You should have a app.json (expo). and a package.json file, check if the expo versions match and change accordingly. For example in my case the problem was that in the app.json file I had a 25.0.0 version for the expo sdkVersion attribute, I change that to 23.0.0 and everything worked.
package.json:
"dependencies": {
"expo": "^23.0.4",
"react": "16.0.0",
"react-native": "^0.50.4"
}
app.json:
{
"expo": {
"sdkVersion": "23.0.0" // before was 25.0.0
}
}
Just go to your android/app/build.gradle and then add to the dependencies section:
dependencies{
compile ("com.facebook.react:react-native:0.50.3") { force = true }
}
/// the react native version can be found in package.json
For Android developers who couldn't get it fixed by just closing and rebuilding, Manually uninstall the app on the emulator/device.
just force react native version in your android's app level gradle file, in the dependencies section.
compile ("com.facebook.react:react-native:0.52.0") { force = true }
worked for me
If you're running your React Native app through Expo, upgrading React Native is liable to cause this error (as noted at https://github.com/expo/expo/issues/923).
If that's your scenario, your options are:
Bump Expo (which is listed in your package.json) to a version that is compatible with your React Native version (if one exists, which may not be the case - judging by the linked issue, I figure that Expo support trails React Native releases).
Discard your changes, delete and reinstall your Node modules, Eject from Expo, and then (after checking that you can still run your app post-ejection) try your upgrade again.
I've never seen this error before, but whenever I can't get Xcode and React-Native to play well together, I do a couple of things. Check what version of Xcode I'm working with. If it needs to be updated, I update it. Then clearing watchman and the cache are the second place I go. I don't use the reset cache command. It always says that I need to verify the cache, so I skip that (you can do it though, I just get confused). I use rm -rf $TMPDIR/react-* to get rid of any cached builds. If that doesn't work, I try to build the app in Xcode, then work my way from there, to build it with react-native run-ios. With this error message, it seems you might start by trying to build it with Xcode. Hope that helps...let me know your progress with it. Good luck! (Also, you could update to RN 0.51 as another attempt to get your versions synced.)
I had this problem for the longest time and none of the above solutions helped. I was in the middle of upgrading react native in a create-react-native-app project until I found out that not all versions of Expo support the latest React Native.
Found this page linked in the documentation that shows which version combinations of React Native, React, and Expo are officially supported:
Source: https://github.com/react-community/create-react-native-app/blob/master/VERSIONS.md
Editing the app.json and package.json files to match the corresponding versions and running npm install got everything working again.
I am using a physical device, in my case this solved the problem:
Uninstall the app
lsof -i :8081
kill -9 PID
Rebuild the app (react-native run-android or react-native run-ios)
In your build.gradle file add the following
implementation ("com.facebook.react:react-native:0.51.0") {
force = true;
}
replace 0.51.0 with the version in your package.json
Try installing the dependencies again. That worked for me-
1.) yarn/npm install
2.) yarn/npm start --reset-cache
For me it was due to react-native version in dependency section of package.json file. It was:
"dependencies": {
"expo": "^27.0.1",
"react": "16.3.1",
"react-native": "~0.55.0"
}
I chaged it to:
"dependencies": {
"expo": "^27.0.1",
"react": "16.3.1",
"react-native": "0.52.0"
}
Now it works fine.
In my case installing a new virtual device helped. Now I am using 1 device per app.
It happens sometimes when you try to run without closing the node server, in which the previous app was running, so try restarting React.To do so, just run the following commands:
1. To kill current processes
killall node -9
2. To Start React Native
react-native start
3. Then Run android
react-native run-android
For my case I'm facing it on iOS, and I've tried to reset and clear all cache using below command but failed too, despite many comments saying that the root cause is there is react packager running somewhere accidentally, I've restarted my mac and the problem still remained.
watchman watch-del-all && rm -rf node_modules/ && yarn cache clean && yarn install && yarn start --reset-cache
The solution is, to delete the build folder # /ios/build, then execute react-native run-ios solved it
I have tried the solutions above but adding this to AndroidManifest.xml seems to fix it.
android:usesCleartextTraffic="true"
For others with the same problem on iOS with CocoaPods:
I tried all of the solutions above, without luck. I have some packages with native dependencies in my project, and some of those needed pod modules being installed. The problem was that React was specified in my Podfile, but the React pod didn't automatically get upgraded by using react-native-git-upgrade.
The fix is to upgrade all installed pods, by running cd ios && pod install.
Expo users - make sure your app.json sdk version and package.json expo version are (may be equal) compatible to each other.
The fix we did was to make sure the ANDROID_HOME and PATH variables were set up prior to the build.
First, run the below two commands then the build the app for the device.
export ANDROID_HOME=/Users/username/MyFiles/applications/androidsdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
This is working for me :
react-native start --reset-cache
I also had this issue using Expo and iOS Simulator. What worked for me was erasing the Simulator in Hardware > Erase All Content and Settings...
I have got the same issue while building my react native app for android and I did the following which worked for me.
The "JavaScript version 0.50.1" in the error console is the react-native version in your package.json file. Make sure it is the same version as "Native version 0.50.0" in the error console.
I have Updated the react-native version to the "Native Version 0.50.0" as prompted in the error console.
Rebuild the app react-native run-android.
Possible Fix:
Delete the package-lock.json
Run: watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/haste-map-react-native-packager-* && rm -rf node_modules/&& npm install
If the problem persists, try to execute the project directly from the Xcode
This worked for me.
In my case (NOT using expo & Android build)
package.json
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.2"
}
And app.json
{
"sdkVersion": "27"
}
resolved the issue
I was trying to build and run a React Native app from WebStorm and ran into this problem. The simple solution for me was:
watchman watch-del-all
On macOS, if watchman is not already installed, install it using Homebrew:
brew install watchman
In my case, I changed the expo version manually. I got the same issue because I forgot to update sdkVersion in app.json and babel-preset-expo in package.json
After that run: expo r -c to clear cache and start the app.
This Answer is Published in 2020,
Fix this Error in 3 steps:
First step: I changed the value of expo in package.json file to the latest supported version, according to expo documents(visit here).
Second step: I changed the value of sdkVersion in app.json file to the same value of expo in package.json.( equal number to last step).
Third step : I changed the value of react-native in package.json file to the same value of React Native Version , according to expo documents(visit here).
now your ready to go.
use npm install to install specified version of dependencies and then npm start to run the project
I got this classing when TypeScript type definitions mismatched.
E.G react-native at 0.61.5 in dependencies and #types/react-native at 0.60.0 in devDependencies.
As soon as I updated devDependencies it worked. Didn't have to restart anything.
edit your package.json for your javascript version
"react-native": "^0.50.1",
after run
npm install
For me, who is running with a monorepo, there was a hidden react-native version inside yarn.lock. It was not present in any package.json, but was never deleted.
I removed that particular react-native version from yarn.lock, and did a
yarn install
This cleaned out alot of old stuff and made sure that things was working fine.
My situation is this :
I had a working copy of a react-native project that was working well. Had it commited to my git repository.
I decided to upgrade react-native to 0.26.3 and then 0.28 and finally ended up in a big dependency mess with collisions. So decided to go back to previous working version. Reverted the changes. Removed node_modules folder from my working directory.
But now npm install just won't work.
My working dependencies in package.json
"dependencies": {
"immutable": "^3.8.1",
"key-mirror": "^1.0.1",
"react": "^15.0.2",
"react-native": "^0.26.0",
"react-native-router-flux": "^3.26.1",
"react-redux": "^4.4.5",
"redux": "^3.5.2",
"redux-thunk": "^2.1.0",
"strformat": "0.0.7"
},
"devDependencies": {
"babel-core": "^6.10.4",
"babel-jest": "^12.1.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react-native": "^1.9.0",
"babel-register": "^6.9.0",
"chai": "^3.5.0",
"fetch-mock": "^4.5.4",
"jest-cli": "^12.1.1",
"mocha": "^2.5.3",
"mockery": "^1.7.0",
"nock": "^8.0.0",
"redux-mock-store": "^1.1.1",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"sinon-stub-promise": "^2.0.0"
}
Now I get
npm ERR! peerinvalid The package react#15.1.0 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer react-native#0.26.3 wants react#15.0.2
npm ERR! peerinvalid Peer react-redux#4.4.5 wants react#^0.14.0 || ^15.0.0-0
This just not makes sense to me, as my react dependency is 15.0.2 and react-native 0.26.0 as you can see in package.json.
Note that this is from a previous commit that was working (the whole lot).
I also did a npm ls. Weirdly wrong dependencies are shown in the tree like wrong versions of react-native, react-native-router-flux, react.
link to ls output
For existing projects if you want to install/downgrade to lower version
npm install react-native#x.x.x ex: npm install react-native#0.43.4
This will install the version specified.
Check the installed version with react-native --version
Update 2020
Just run
npm install react-native#0.43.8
Replace 0.43.8 with version you need.
Please update your react dependency in package.json to explicitly be 15.0.2, not ^15.0.2 since the latter resolves to 15.1.0 which causes this issue. It is recommended to leave it that way until you upgrade for the next time and get this error once again (to avoid react changing its version in the meantime and react-native not being ready for it).
Also, with npm3 EPEERINVALID is no longer an error, but warning.
Downgrading React Native requires manual steps. I recommend using https://react-native-community.github.io/upgrade-helper/ and here are my steps
Set your current version as base and select the previous minor version of react-native
Revert all the changes made to files as displayed in the compare view in step 1
Delete node_modules folder, clear watchman, reset metro cache, delete pods, clear ios and android cached files. npx react-native-clean-project is super helpful.
yarn or npm install and reinstall pods for ios
Make sure all your jest tests, detox tests and manually testing both iOS and Android are working as expected.
(if needed) Repeat the steps to downgrade to another lower version
Suggestion: If you're downgrading multiple minor versions then it might be easier to downgrade one version at a time. For example, downgrading from 0.61.x to 0.58.x, would be less work to downgrade to version 0.60.x first, test and make sure everything works in iOS and Android then move on
Try npm prune and then npm i again.
The command npm prune will basically remove all unwanted packages, and npm i will make sure all missing packages are installed.
If you're using react-native you can modify your package.json file with the versions that you need and then delete all your node modules rm -rf node_modules and then reinstall npm install
If you change the version in Package.json and reinstall npm packages it will make build errors. Please refer and downgrade/upgrade to a specific version.
I tried to downgrade from react-native 0.71.1 to 0.70.4 with just npm i react-native#0.70.4 and fix whatever errors came up. In my case I needed this because the package react-native-vision-camera was not yet compatible with react-native 0.71.1.
But I had dozens of errors, which after I while I started to understand are due to the fact that the whole android folder that is being set up from a template when you run the npx react-native init script, has differences and must match the react-native package version. So I guess if you downgrade a minor version in this way, not just a patch, you are just very lucky if it works somehow. I would not do it.
I instead decided to freshly init react-native with the desired version:
Just git commit all your changes and push them to the remote (to be safe), mv your current project folder to a different name.
Run npx react-native init <YourProjectName> --version 0.70.6 to get the desired version, but make sure to use the same ProjectName, otherwise you might have configuration mismatches.
Integrate your own code from the old project folder (if you forget something git will tell you later), merge configuration files, etc.
add packages by running npm install <package-name> <package-2-name> <etc.) and npm install -D (for devDependencies). Don't copy the dependencies / devDependencies over from package.json, as that way you'll probably not get the right package versions that match your versions of react, react-native etc.
finally copy .git folder from your old project folder into the new one, and check the changes, to make sure you did not forget anything. And then you will actually see all the differences in the template I mentioned above. In my case more than 30 files were different between those minor versions.
I'm trying to get grunt.js set up on my work machine. Now I've managed to get it set up at home, so I pushed my repository, then cloned it on my work machine, however despite troubleshooting this to death I've always run into the same issue when I come to try and run the command on my work computer;
sh.exe": grunt: command not found
So some background and explanation;
I'm using Aptana 3.0 and running all my commands through the terminal. (This applies to my home and work computer)
I cloned the "working" repository and put it in a folder on my work machine, so I have my package.json and gruntfile.js files inside said directory. These work fine on my home computer and I am able to run the watch task set up in my gruntfile.js successfully at home.
I've run npm install grunt-cli -g and npm install inside my project on my WORK computer and installation has been successful each time. My only error messages on either are a lack of description and a repository field which, to my knowledge these aren't mandatory?
The node modules folder inside my repository indicates I have the following installed (as per my package.json)
grunt
grunt-contrib-compass
grunt-contrib-uglify
grunt-contrib-watch
matchdep
Now I'm pretty green to this command line stuff, so I may have overlooked something very obvious but I feel like I've tried every guide going to get this thing to work.
Despite running through the getting started steps/installing grunt documentation repeatedly, it seems no matter what I do the terminal will not pick up grunt as a recognized command.
Am I stupid or is this some other issue?
EDIT 1: contents of my package.json:
{
"name" : "xxxxxxxxx",
"version" : "xxxx",
"dependencies" : {
"grunt":"~0.4.1",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-compass": "~0.5.0",
"grunt-contrib-uglify": "~0.2.2",
"matchdep": "~0.1.2"
}
}
This is happening because you are using the Aptana Terminal, which needs the PATH variable to work out what is meant by grunt etc. A normal cmd prompt would work fine with the command npm install grunt-cli -g but in this context the terminal is unaware of what grunt is.
As per the following existing answer, you need to set up your Windows PATH variable to make the Aptana Terminal aware of the npm directory: https://stackoverflow.com/a/19137584/463205
C:\Users\Username\AppData\Roaming\npm
Closing the terminal and reopening it after setting the PATH correctly should enable you to run the command successfully.
Try to run
npm install grunt-cli -g
On your home computer.
-g means - install Grunt globally (not in the project node_modules folder), so it'll add grunt command to the bin folder which is used by nodejs console ( and you need to run node.js command prompt, not just arbitrary cmd)