Expo React Native couldn't start project on Android: "The system cannot find the path specified"

Viewed 7246

Before I update my Expo cli there is no problem when I run React Native project in Android emulator (from Android Studio) I can run it from localhost, but after I updated my expo cli I got this error:

Metro Builder error

I can't run my project in emulator, but if I connected my phone to my laptop using the hotspot, I can run my project, but I must copy the link from the metro builder to Expo apps. Like this:

Link from metro builder when I connected to phone

and I must copy that URL to expo like this to run the project:

Expo app

And my project running, but when I clicked "Run on android device / emulator" it will shows the error in the title.

Before I update to Expo cli v 3.15.4 there is no problem, I can run my project without hotspot, localhost only.

And if run without hotspot, the project doesn't run, it will give me an error.

5 Answers

I faced the same issue. I solved the problem changing the path of my ANDROID_HOME environment variable. It was wrong!!! Make sure that the path points to your android sdk location, by default the path is something like this: C:\Users\YourUser\AppData\Local\Android\Sdk

I also updated my "path" system variable adding these two paths: C:\Users\YourUser\AppData\Local\Android\Sdk\platforms C:\Users\YourUser\AppData\Local\Android\Sdk\platform-tools

I hope it solves your problem too. Good luck!

Roll back your Expo version to the previous version that was working. Sometimes breaking changes go into the release. Unless you upgraded because of a new feature, this is OK. Open an issue on their GitHub so they know about this. Also, double check that you did not reorganise files in your folder or change any paths in the code hence the path error.

Nothing to be worried about this if you are using expo. Just open any emulator and install expo on the emulator then copy LAN connection from metro run after this open expo app in emulator just paste that link in clipboard now relax and chill your app is build on emulator.

I was facing the same issue. Also, in my case, I have installed node.js in a different directory(D) and was getting the same error. So all I did was updating my "Path" system variable with the location of the folder where "expo-cli" was installed(C:\Users\username\AppData\Roaming\npm) and it worked for me.

In addition to these answers, I found this post which mentions that the checking of "adb" in expo is via this function:

function whichADB() {
  if (process.env.ANDROID_HOME) {
    return `${process.env.ANDROID_HOME}/platform-tools/adb`;
  }
  return 'adb';
}

This really clarifies what needs to be done which are to either:

  • Add ANDROID_HOME in environment variables with path value of your Sdk installation (commonly in C:\Users\{User}\AppData\Local\Android\Sdk

or

  • Append C:\Users\chual\AppData\Local\Android\Sdk\platform-tools under Path in your environment variables. If you choose this method, make sure that you do not have incorrectly configured ANDROID_HOME in your environment variables because that will take precedence over this.

As a side note, notice that ANDROID_HOME only points up to Sdk folder while in Path, it is upto platform-tools.

Related