8

Every time I try to react-native link a new library, I get the same error message. Here it is for react-native-video.

rnpm-install info Linking react-native-video android dependency rnpm-install ERR! Something went wrong while linking. Error: ENOENT: no such file or directory, open '/Users/Me/Projects/myProject/android/app/src/main/java/com/companyName/appName/MainApplication.java' Please file an issue here: https://github.com/facebook/react-native/issues

The actual location of my MainApplication.java file is

./android/app/src/main/java/com/appName/MainApplication.java

The difference is that React Native Link is including "company name" in the path, which doesn't match my project.

How can I fix this?

Freewalker
  • 6,329
  • 4
  • 51
  • 70

4 Answers4

7

I looked over some topic and found solution, you can try with:

npm install --save-dev babel-plugin-module-resolver and then add your npm install package & react-native link again.

Good luck

My Mai
  • 1,073
  • 9
  • 10
  • 1
    Thanks for your answer, It works, One reason is, if you are trying to resolve modules using package.json file in your project folders, you will get this linking problem. If you use this babel plugin, you will solve both linking and module resolve problems – mahi May 24 '18 at 20:40
  • i installed realm db and change the setting of mainapplication as per req but its throwing error app:debugjavawithkavac error what the solution – arslan Aug 22 '20 at 04:50
5

I'm pretty late to the party on this, but for future reference;

TLDR: Adding another folder like so java/com/companyName/AppName/ will fix your issue.

After updating to the latest react-native I had this issue too. Your android path contains your apps ID so com.test.app path should be android/app/src/main/java/com/test/app.

Looking at your error message, its actually telling you where it's expecting the file to be;

Error: ENOENT: no such file or directory, open '/Users/Me/Projects/myProject/android/app/src/main/java/com/companyName/appName/MainApplication.java'

If you create another folder like so java/com/companyName/AppName/ you will be able to automatically link plugins.

Mark
  • 2,061
  • 1
  • 16
  • 26
2

Another way I tried and it works for me: rm -rf node_modules && npm install

Then retry install your package: ex: npm install react-native-image-picker@latest --save

Then react-native link your package react-native link react-native-image-picker

My Mai
  • 1,073
  • 9
  • 10
0

There are only two options that i am aware of to solve this problem

  1. close all the terminals to stop the node server running on a difference terminal.

    • If you still have the mistake after that then try the following option You might still have the error because you uninstall and re-install react-native without paying attention to the version that you installed which for most case will be the latest version. So double check the current version of your react-native when installing it. "\n"
  2. so either

    • in your package.json you add "react-native": "^0.60.5" if the version is 0.60.5 replace "^0.60.5" by the version you are trying to run, in devDepencies and run npm install or
    • run npm install react-native@0.60.5 or npm install react-native@version
Kalana
  • 5,631
  • 7
  • 30
  • 51
Pascal Nitcheu
  • 667
  • 7
  • 8