Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Exception in HostObject::get for prop > 'NativeUnimoduleProxy' - Android Virtual Device (AVD) crashes using Expo to test React Native App

Problem

I want to test/emulate a newly created default React Native App.

However, opening an Android Virtual Device (AVD) from the Expo Terminal in Visual Studio Code raises 2 Uncaught Errors:

ERROR Error: Exception in HostObject::get for prop 'NativeUnimoduleProxy': java.lang.SecurityException: Permission Denial: registerScreenCaptureObserver from pid=7315, uid=10197 requires android.permission.DETECT_SCREEN_CAPTURE

ERROR Invariant Violation: "main" has not been registered.

How to reproduce the error

I followed the official React Native documentation for the Expo Go Quickstart running the npm commands:

npx create-expo-app AwesomeProject
cd AwesomeProject

which successfully creates a new React Native Project.

To test/emulate the default App.js a server is successfully started in the Visual Studio Code Terminal with the command

npx expo start

Now I start Android Studio and open the Virtual Device Manager. I successfully start the newly created Pixel 7 Device. The AVD opens without issues and shows the device as you would expect.

Back in the Visual Studio Code Terminal I press a to open Android Virtual Device emulation with Expo.

a

The focus automatically switches to the AVD, it even finished "bundling 100%" but then shows 2 Uncaught Errors on the AVD:

enter image description here

and also in the Visual Studio Code Expo Terminal

enter image description here

like image 509
swbergmann Avatar asked Jan 22 '26 10:01

swbergmann


1 Answers

Use an older Android API Version when creating your Android Virtual Device (AVD).

This error happens only when using an AVD running the latest Android API Versions i.e.:

  • VanillaIceCream and
  • UpsideDownCakePrivacySandbox.

After testing extensively it turned out that Android Virtual Devices with API 31 to API 34 and also API TiramisuPrivacySandbox work just fine.

With these API Versions there are no errors and the React Native App is emulated automatically and correctly by simply pressing a in the Visual Studio Code Terminal.

like image 150
FL00R Avatar answered Jan 24 '26 14:01

FL00R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!