Rebecca Campbell
Rebecca Campbell

Reputation: 835

Android app built for release still trying to connect to localhost:8081

I'm trying to get an alpha build of my React Native app on my Android phone, but when I open it, it immediately crashes. Fortunately, it's instrumented so I can see that the errors are all because it's still trying to connect to the metro server, which I would expect from a debug build, but I can't figure out how to prevent these calls in a release build. Here are the errors:

Cannot connect to host http://localhost:8081/inspector/device
Cannot connect to host http://localhost:8081/message

Steps taken:

Possibly pertinent information:

----------- UPDATE July 23 ------------

After a few changes, I've moved onto an error where the 3rd party auth screen won't load. Here's what changed:

I still need to debug authentication, but it looks like I've probably moved on to a new issue. I'll still do some digging to see if I can narrow in on what actually caused the issue.

----------- UPDATE Later on July 23 ------------

All is well now, though I don't know what made the difference. Builds got into a strange state after my last update, and I ended up deleting my .gradle folder after reading this. I also updated gradle, and my theory at this point is that the upgrade combined with deleting that folder was the actual fix.

I've re-installed the monitoring software and didn't have any trouble.

Upvotes: 2

Views: 895

Answers (1)

Rebecca Campbell
Rebecca Campbell

Reputation: 835

Should anybody else run into this, I would look at cleaning up the Android build. Steps I would try in order:

  1. From the android folder, run ./gradlew clean, then re-build
  2. If that doesn't work, delete the .gradle folder as seen in the accepted answer here
  3. Check your gradle version, upgrade if it's out of date

Upvotes: 1

Related Questions