Monday, July 3, 2017

React native link creates duplicated entries

Leave a Comment

Hellow,

I don't know why react-native link is creating duplicated entries in MainApplication.java (at imports and in getPackages function) and in app/build.gradle the compile project entry is not being added, but if I run again the command, I receive the same message instead of that the module is already linked.

When I run react-native link, I receive the messages that the module has been linked successfully on Android (duplicated) and in iOS it was already linked.

react-native link result

2 Answers

Answers 1

Faced a similar issue when I tried to link a library to my code. On running the react-native link command, it displayed that the library has been linked successfully though the entries were never created. What I did was to manually modify these 3 files:

  1. android/settings.gradle: Add the module using include() and specify the path of your project directory.

    include ':your_package_name' project(':your_package_name').projectDir = new File(rootProject.projectDir,'../node_modules/your_package_name') 
  2. android/app/build.gradle: Add the compile statement

    compile project(':your_package_name') 
  3. android/app/src/main/java/[..project_name..]/MainApplication.java: Import the package and make sure that the getPackages() is returning your package along with the previous ones.

Would have answered you better if you specified the name of the required library

Answers 2

In my case, It was related with RN version and local libraries.

I solved it by removing the duplicated libraries on Xcode.

Here is link

Hope it give you some help.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment