react-native: Dev mode trying to find /index.android.bundle (Unable to resolve module `./index.android` from ``)

Hello,

I upgraded from RN 0.59.9 to 0.61.0.rc3.

On Android, when I compile the app (after yarn install and cleaning the Android project), I have a red crash error saying :

Error: Unable to resolve module `./index.android` from ``:

None of these files exist:
  * index.android(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.svg|.native.svg|.svg)
  * index.android/index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.svg|.native.svg|.svg)
    at ModuleResolver.resolveDependency (/Users/jbchauvin1/Documents/Projets/Santoyamo/Cegedim/new/Mobile/app-dev/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:163:15)
    at ResolutionRequest.resolveDependency (/Users/jbchauvin1/Documents/Projets/Santoyamo/Cegedim/new/Mobile/app-dev/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (/Users/jbchauvin1/Documents/Projets/Santoyamo/Cegedim/new/Mobile/app-dev/node_modules/metro/src/node-haste/DependencyGraph.js:282:16)
    at /Users/jbchauvin1/Documents/Projets/Santoyamo/Cegedim/new/Mobile/app-dev/node_modules/metro/src/lib/transformHelpers.js:267:42
    at Server.<anonymous> (/Users/jbchauvin1/Documents/Projets/Santoyamo/Cegedim/new/Mobile/app-dev/node_modules/metro/src/Server.js:1088:41)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/jbchauvin1/Documents/Projets/Santoyamo/Cegedim/new/Mobile/app-dev/node_modules/metro/src/Server.js:99:24)
    at _next (/Users/jbchauvin1/Documents/Projets/Santoyamo/Cegedim/new/Mobile/app-dev/node_modules/metro/src/Server.js:119:9)

And my app/build.gradle :

project.ext.react = [
    entryFile: "index.js",
    bundleAssetName: "index.android.bundle",
    bundleInDebug: false,
    bundleInRelease: true,
    enableHermes: false,  // clean and rebuild if changing
]

React Native version: 0.61 RC 3

Steps To Reproduce

  1. react-native run-android
  2. Red crash error…

Describe what you expected to happen: I would like to see the Android app without any problems. That’s weird, I don’t understand why it’s trying to load the index.android.bundle file.

Thanks for the help

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 16

Most upvoted comments

Hi JB-CHAUVIN, Came across the exact same issue this morning, here is my steps to solve the issue

  1. Remove the bundleAssetName from project.ext.react (in app/build.gradle)
project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,  // clean and rebuild if changing
]
  1. Please make sure the function getJSMainModuleName() exist in MainApplication.java
public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      @SuppressWarnings("UnnecessaryLocalVariable")
      List<ReactPackage> packages = new PackageList(this).getPackages();
      // Packages that cannot be autolinked yet can be added manually here, for example:
      // packages.add(new MyReactNativePackage());
      return packages;
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

solution by @tsehiuming solve my problem. i missed out

@Override
    protected String getJSMainModuleName() {
      return "index";
    }

in my MainApplication.java