javareact-nativereact-native-linking

React-native link path incorrect


I have an app which fails on linking/unlinking packages, similar to this issue.

It specifically fails on linking the MainApplication.java file with this error.

error Something went wrong while unlinking. Reason ENOENT: no such file or directory, open './AppName/android/app/src/main/java/co/AppName/AppName/MainApplication.java'

The path is actually incorrect java/co/AppNAme should be java/com/AppName.

I can't find anywhere what could be causing this or any documentation on how to set the path.

I've tried using babel-plugin-module-resolver but no success, unless im missing something. Anyone had a similar problem?


Solution

  • TLDR: Adding another folder like so java/co/AppNAme/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.

    You've stated;

    The path is actually incorrect java/co/AppNAme should be java/com/AppName.

    This isn't correct as looking at your error message, its actually telling you where its expecting the file to be;

    no such file or directory, open java/co/AppName/AppName/MainApplication.java

    If you create another folder like so java/co/AppNAme/AppName/ it will fix your issue.