expo: [Expo 50] Unable to load dev client bundle on Android device

Minimal reproducible example

https://github.com/stefan-schweiger/expo50-prebuild-bug

Summary

After upgrading my app from SDK 49 to SDK 50 and building a new dev client my app stopped to correctly load bundles on my physical Android device. It works fine on an iPhone.

When I connect the dev client the development server I don’t see the usual BUNDLE ./index.js in the console and I get this error in the app itself:

There was a problem loading the project.

This development build encountered the following error.

Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.

I’ve created a reproduction which is basically just the Expo 50 template with the dev client installed. To build I’m using the following steps:

  • npx expo prebuild -p android --clean
  • cd ./android
  • ./gradlew app:assembleDebug
  • Install the apk from ./android/app/build/outputs/apk/debug on your physical device
  • npx expo start
  • Connect to the dev server

The weird thing is if I only do expo run:android the app opens up as expected on the emulator and works.

I have reproduced this behavior between a Windows and a Mac as the server host. The same application works fine with SDK 49.

Environment

  expo-env-info 1.0.5 environment info:
    System:
      OS: macOS 14.2.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 21.5.0 - /opt/homebrew/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 10.2.4 - /opt/homebrew/bin/npm
      Watchman: 2023.12.04.00 - /opt/homebrew/bin/watchman
    Managers:
      CocoaPods: 1.14.3 - /opt/homebrew/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 23.2, iOS 17.2, macOS 14.2, tvOS 17.2, watchOS 10.2
    IDEs:
      Xcode: 15.1/15C65 - /usr/bin/xcodebuild
skdmanager --list

  Path                                           | Version      | Description                             | Location                                      
  -------                                        | -------      | -------                                 | -------                                                             
  build-tools;30.0.3                             | 30.0.3       | Android SDK Build-Tools 30.0.3          | build-tools/30.0.3                            
  build-tools;31.0.0                             | 31.0.0       | Android SDK Build-Tools 31              | build-tools/31.0.0                            
  build-tools;33.0.0                             | 33.0.0       | Android SDK Build-Tools 33              | build-tools/33.0.0                            
  build-tools;33.0.1                             | 33.0.1       | Android SDK Build-Tools 33.0.1          | build-tools/33.0.1                            
  build-tools;34.0.0                             | 34.0.0       | Android SDK Build-Tools 34              | build-tools/34.0.0                            
  cmake;3.18.1                                   | 3.18.1       | CMake 3.18.1                            | cmake/3.18.1                                  
  cmake;3.22.1                                   | 3.22.1       | CMake 3.22.1                            | cmake/3.22.1                                  
  cmdline-tools;5.0                              | 5.0          | Android SDK Command-line Tools          | cmdline-tools/5.0                             
  cmdline-tools;latest                           | 12.0         | Android SDK Command-line Tools (latest) | cmdline-tools/latest                          
  emulator                                       | 33.1.24      | Android Emulator                        | emulator                                      
  ndk;21.4.7075529                               | 21.4.7075529 | NDK (Side by side) 21.4.7075529         | ndk/21.4.7075529                              
  ndk;23.1.7779620                               | 23.1.7779620 | NDK (Side by side) 23.1.7779620         | ndk/23.1.7779620                              
  ndk;24.0.8215888                               | 24.0.8215888 | NDK (Side by side) 24.0.8215888         | ndk/24.0.8215888                              
  ndk;25.1.8937393                               | 25.1.8937393 | NDK (Side by side) 25.1.8937393         | ndk/25.1.8937393                              
  patcher;v4                                     | 1            | SDK Patch Applier v4                    | patcher/v4                                    
  platform-tools                                 | 34.0.5       | Android SDK Platform-Tools              | platform-tools                                
  platforms;android-30                           | 3            | Android SDK Platform 30                 | platforms/android-30                          
  platforms;android-31                           | 1            | Android SDK Platform 31                 | platforms/android-31                          
  platforms;android-32                           | 1            | Android SDK Platform 32                 | platforms/android-32                          
  platforms;android-33                           | 3            | Android SDK Platform 33                 | platforms/android-33                          
  platforms;android-34                           | 2            | Android SDK Platform 34                 | platforms/android-34                          
  sources;android-31                             | 1            | Sources for Android 31                  | sources/android-31                            
  sources;android-34                             | 2            | Sources for Android 34                  | sources/android-34                            
  system-images;android-31;default;arm64-v8a     | 4            | ARM 64 v8a System Image                 | system-images/android-31/default/arm64-v8a    
  system-images;android-31;google_apis;arm64-v8a | 11           | Google APIs ARM 64 v8a System Image     | system-images/android-31/google_apis/arm64-v8a
  system-images;android-33;google_apis;arm64-v8a | 15           | Google APIs ARM 64 v8a System Image     | system-images/android-33/google_apis/arm64-v8a
  system-images;android-34;google_apis;arm64-v8a | 12           | Google APIs ARM 64 v8a System Image     | system-images/android-34/google_apis/arm64-v8a
Android Device:
  Oneplus 6T
  Android 11

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Reactions: 16
  • Comments: 64 (18 by maintainers)

Commits related to this issue

Most upvoted comments

Seeing the same issue, I have to be connected to ADB and reverse 8081 for it to work. Previously I didn’t need to be connected to ADB and could use the network IP - it even finds that network IP in the dev client and shows a green online status, but get the same error. It looks like some change when not connecting by “localhost” that is causing this

for me it only works with cable after adb reverse tcp:8081 tcp:8081 still a regression unfortunately

This issue should not be closed. There is currently a massive regression of functionality between v49 and v50. If ignored now, you will have an influx of bug reports when releasing to stable.

yep - we’ve just upgraded from expo 49 to 50 and are we’re now encountering this error when attempting to use development builds (wirelessly) via expo start on Android, which was working perfectly fine in 49.

im also facing the same problem after upgrading to sdk 50

@brentvatne thanks. indeed, expo-dev-client 3.3.7 wasn’t published yet on npm when I posted my comment. everything works fine now.

This issue should not be closed. There is currently a massive regression of functionality between v49 and v50. If ignored now, you will have an influx of bug reports when releasing to stable.

Actually, same for me, sorry for the duplicate.

same error on android SDK 50:

There was a problem loading the project.

This development build encountered the following error.

Unable to load script. Make sure you’re either running Metro (run ‘npx react-native start’) or that your bundle ‘index.android.bundle’ is packaged correctly for release.

@alanjhughes Just tried it and it works when I run: adb reverse tcp:8081 tcp:8081

A little surprised though because it was clearly able too access the metro server via that port already?

Screenshot_20240119_030937_Submind 50.jpg

Same problem on Android

Update: It is working now

@stefan-schweiger When you get the error, have you an emulator open? I reproduced but can fix it by running adb reverse tcp:8081 tcp:8081 This fixes it for me whether wireless debugging is off or on

Thank you for posting this. It helped me get my dev-client back and operational where I had timeouts connecting to the metro server.

For anyone interested, I am running on ChromeOS, and this requires me to build a dev-client on eas, which then I can adb install and go from there. Previously it did not require this adb reverse command.

The fast refresh problem is a separate issue so I’ll close this. The solution when you encounter this problem when running on a real device is to run adb reverse tcp:8081 tcp:8081 which is also called out in the react-native docs

@stefan-schweiger When you get the error, have you an emulator open? I reproduced but can fix it by running adb reverse tcp:8081 tcp:8081 This fixes it for me whether wireless debugging is off or on