Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getPackages() method in MainApplication.java, the module might be created twice

I'm trying to integrate Razorpay with my react-native application using there official documentation from- https://razorpay.com/docs/payment-gateway/react-native-integration/standard/android/ but I'm getting this exception while running the application. No duplicate imports are there inside the MainApplication.java.

like image 394
Sandip Biswas Avatar asked Mar 09 '20 21:03

Sandip Biswas


2 Answers

In step 2 of setting up react-native-razorpay, I was adding these 2 lines in MainApplication.java:

import com.razorpay.rn.RazorpayPackage;

and

packages.add(new RazorpayPackage());

I got rid of this error by removing these 2 lines. The package is automatically added later on during build time by autolinking. Removing these 2 lines solved my issue.

like image 199
mohit arora Avatar answered Sep 19 '22 09:09

mohit arora


I had a similar error but with a different package. Looks as though the packages are added much later I have no idea when and how though. React Native "^0.64.0"

Native module Orientation tried to override OrientationModule. Check the getPackages() method in MainApplication.java, it might be that module is being created twice.

Solution

In MainApplication.java:

  1. I had to remove or comment out duplicate import of OrientationPackage

// import com.github.yamill.orientation.OrientationPackage; <----- Commented out or removed

  1. And not add the package to List<ReactPackage>

// packages.add(new OrientationPackage()); // <----- Commented out or removed

like image 45
Phelang Avatar answered Sep 21 '22 09:09

Phelang