skip to Main Content

I’ve just created an Expo Project with the following command:

npx create-expo-app@latest --template tabs@50

I have everything I need installed (I think?): Android Studio, Xcode, etc.
When running npm start android, the emulator opens and then crashes with this error:

 ERROR  Error: Exception in HostObject::get for prop 'NativeUnimoduleProxy': java.lang.SecurityException: Permission Denial: registerScreenCaptureObserver from pid=2093, uid=10182 requires android.permission.DETECT_SCREEN_CAPTURE, js engine: hermes
 ERROR  Error: Exception in HostObject::get for prop 'NativeUnimoduleProxy': java.lang.SecurityException: Permission Denial: registerScreenCaptureObserver from pid=2093, uid=10182 requires android.permission.DETECT_SCREEN_CAPTURE, js engine: hermes
 ERROR  Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes

I have not modified anything in the project. What does this error mean?

I tried just creating the project with the template (from expo docs).
Expected the app to open in Android Emulator, but it crashes.

2

Answers


  1. I managed to get this working after a few steps. I’m not sure if these are all necessary, and I’m not sure if this includes everything I did since I tried many things before getting it to work, but hopefully this at least helps.

    1. Add the missing permission to the projects: app.json file.
      {
        "expo": {
          "android": {
            "permissions": [
              "android.permission.DETECT_SCREEN_CAPTURE"
            ]
          }
        }
      }
      
    2. Update the version of expo being used: yarn expo upgrade
    3. Ensure xcode is set up properly to prevent issues with glog: sudo xcode-select --switch /Applications/Xcode.app
    4. Install JDK if you don’t already have it installed. I opted to use OpenJDK, which can be downloaded here. If you’re using macOS with an Apple M1 chip, you can follow these directions. Ensure that the path to these binaries is added to your PATH variable (i.e.: update your ~/.bashrc or ~/.zshrc file).
    5. Try prebuilding: yarn expo prebuild
    6. Run your project in Android VM: yarn android
    Login or Signup to reply.
  2. If you´re experiencing this error with expo go, your emulator Android System Image is probably "too new". For me "VanillaIceCream" API level wasn’t working. Others reported on the expo discord, that "UpsideDownCakePrivacySandbox" wasn’t working either. I took "UpsideDownCake" / API Level 34 which worked for me. According to official expo docs "Tiramisu" also works. I did not try "TiramisuPrivacySandbox".
    Here is a screenshot of Android Studio Device Manager enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search