Ajay Sivan
Ajay Sivan

Reputation: 2989

React native auto linking issue in Android (RN 0.61.5)

I was using react-native 0.59.1 and recently migrated to react-native 0.61.5 after that when I run react-native run-android I get the following error.

enter image description here

Even with the error the project builds and run properly.

I have heard about auto-linking and as suggested in the error I have unlinked the dependency using the command shown in the error and also run react-native link. After that, the project builds and works fine in iOS but throwing the following error in Android

enter image description here

Upvotes: 3

Views: 1468

Answers (2)

Ajay Sivan
Ajay Sivan

Reputation: 2989

It was a problem with my react-native upgrade. I haven't updated the MainApplication.java file properly. I have fixed it by updating getPackages() method in MainApplication.java file as follow

@Override
protected List<ReactPackage> getPackages() {
  @SuppressWarnings("UnnecessaryLocalVariable")
  List<ReactPackage> packages = new PackageList(this).getPackages();
  return packages;
}

Now everything works properly.

Upvotes: 1

Eduardo Carloto
Eduardo Carloto

Reputation: 41

First, you need to try to run react-native unlink netinfo. Once you've unlinked the library you should use cocoapods, not react-native link .... This is because in React Native v0.61 you no longer manually link 3rd party libraries. Try running:

cd ios
pod install

Upvotes: 4

Related Questions