Solved: Unable to resolve module AccessibilityInfo

While building a react-native app, we sometimes encounter an error that says:

Unable to resolve module `AccessibilityInfo`: Module does not exist in the module map 

So, what is the cause of this error and how do we solve it?

This error is due to the version of react-native used. Most likely, you are using react-native 0.56.0, which has this bug.

The solution is hence simple- to upgrade the react native version.

There are multiple ways to do this, so let’s look at two of them.

Editing package.json

  1. Open package.json located at your project root directory.
  2. In the dependencies block, you will see react and react-native. Change the react version to 16.5.1 and the react-native version to 0.57.0.
  3. In your terminal, run npm install , which will install the new versions of react and react-native.
  4. Next, run the command react-native upgrade and enter ‘y’ whenever prompted for a file replacement.

Upgrading from the Terminal

  1. In the terminal, make sure your working directory is the project root directory. Use following commands to upgrade react and react-native respectively:
$ npm install --save react@16.5.1
$ npm install --save react-native@0.57.0

2. Run react-native upgrade and enter ‘y’ whenever prompted for a file replacement.

Your react and react-native should have been upgraded to the respective versions, and you can now run react-native run-android to see that the error due to the AccessibiltyInfo module has vanished.

Note: In case you get the following error:

Execution failed for task ':app:compileDebugJavaWithJavac'.

Go to /android/app/src/main/java/com and make sure the location consists of only one directory containing the MainActivity.java and MainApplication.java files.

In case you have two, check the one that was created when you used the command react-native upgrade. That is the one you want to keep. Delete the other one.

Also, open your AnroidManifest.xml file, located in /android/app/src/main and make sure the package at the top of the file is com.<directory> where <directory> is the directory containing the two .java files.

Written by

I’m a undergrad at BITS Pilani, Goa Campus, expecting to graduate in 2022. I love coding and writing about technical stuff.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store