Reputation: 3975
I recently encountered a problem I didn't have before...
Running react-native link
causes code to be added to the android files that has already been added (tries to link dependencies that have already been linked. Any ideas why this would be happening?
"dependencies": {
"lodash": "^4.17.4",
"react": "16.2.0",
"react-native": "0.52.3",
"react-native-blur": "^3.2.2",
"react-native-fabric": "^0.5.1",
"react-native-fbsdk": "^0.7.0",
"react-native-firebase": "^3.3.1",
"react-native-iap": "^0.2.17",
"react-native-loading-spinner-overlay": "^0.5.2",
"react-native-mail": "^3.0.5",
"react-native-onesignal": "^3.0.9",
"react-native-sound": "^0.10.9",
"react-native-splash-screen": "^3.0.6",
"react-navigation": "^1.0.0-beta.23",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-action-listeners": "^1.0.2",
"redux-thunk": "^2.2.0"
},
Upvotes: 1
Views: 382
Reputation: 87
If command react-native link has been already hit before then all the dependancies will be added twice.
To avoid this always specific link library like this :
react-native link < Your Library Name >
To remove duplicate dependancies remove duplicate entries from following files:
1. build.gradle (Check dependancies)
2. setting.gradle
3. MainApplication.java (Check imports and getPackages())
Upvotes: 1
Reputation: 1441
As mentionned by Pritish there was an issue in react-native calling react-native link
links or re-links all android library meaning that it will call link script associated with your dependencies. A solution is to link only newly added library by calling react-native link <LIBRARY_NAME>
.
For instance
If in your project you use react-native-camera and react-native-fs calling react-native link
will link both react-native-camera
and react-native-fs
.
Now assuming you have already linked react-native-camera
and you didn't add react-native-fs
. After adding react-native-fs
as a dependency if you want it to be linked (without relinking react-native-camera
) call : react-native link react-native-fs
Hope it helps.
Upvotes: 1
Reputation: 22209
This error was due to wrong code in the file link.js
earlier, in this line.
const isInstalled = linkConfig.isInstalled(project[platform], dependency.config[platform]);
It is fixed by this commit and the latest link.js
also has the fixed code, replaced by this line
const isInstalled = linkConfig.isInstalled(project[platform], dependency.name, dependency.config[platform]);
Here's a link to the issue
Upvotes: 1