Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native: Android Native Module

I implemented a native module on the React Native / Android Project. In the Android native project, I used startActivity function to move to the new activity I created manually. I will share some of the codes.

//MainApplication.java

public class MainApplication extends MultiDexApplication {
  ...
  // Needed for `react-native link`
  public List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
      new AnExampleReactPackage(this)
    );
  }
  ...
}

Here, if I use the code new MainReactPackage() then I see the error while running the app on my Android device.

Native module AccessibilityInfoModule tried to override AccessibilityInfoModule for module name AccessibilityInfo. If this was your intention, set canOverrideExistingModule=true

But I'm not sure how I can set the canOverrideExistingModule. How can I solve this?

Relative Question: React Native: Android activity go back

like image 290
Roy Wang Avatar asked May 04 '26 12:05

Roy Wang


1 Answers

Check your

MainApplication.java

(under .\android\app\src\main\java\com\projectName) To see if you have the duplicate declarations in method getPackages().

and also check in import.

like image 111
Mahendra Pratap Avatar answered May 06 '26 01:05

Mahendra Pratap



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!