Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native link can't find my MainApplication.java file

Tags:

react-native

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?

like image 516
Freewalker Avatar asked Jan 03 '18 19:01

Freewalker


Video Answer


2 Answers

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

like image 139
My Mai Avatar answered Oct 21 '22 11:10

My Mai


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.

like image 42
Mark Avatar answered Oct 21 '22 12:10

Mark