Skip to content

Instantly share code, notes, and snippets.

@abdullahceylan
Last active August 10, 2023 23:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdullahceylan/a3738c184abd1e79ccecaad6f53b0ffe to your computer and use it in GitHub Desktop.
Save abdullahceylan/a3738c184abd1e79ccecaad6f53b0ffe to your computer and use it in GitHub Desktop.
Expo - React Native issues and solutions

Problem 1

Invariant Violation: requireNativeComponent: "ViewManagerAdapter_ExpoLinearGradient" was not found in the UIManager.

This is because some of the packages (peer dependencies of 3rd parties) use a different version of expo-linear-gradient. You can solve this by adding the version you want to use in the resolutions section of package.json

  "resolutions": {
    "expo-linear-gradient": "~11.4.0"
  }

Problem 2

onFocus and onBlur events doesn't work with Touchable* components on Expo Go

There is a new react-native-tvos package that was created on top of react-native package. So the releases also will be based on a public release of react-native. To fix the actual issue on TVs you should change your package.json imports to import react-native as follows, so that this package is used instead of the core react-native package.

"react-native": "npm:react-native-tvos@latest"

Details at https://github.com/react-native-tvos/react-native-tvos

Problem 3

You solved the onFocus and onBlur issues on Expo Go but now it doesn't work on TVs with generated/published/development APKs

Because expo is reverting your react-native import in package.json back to the original package while it's extracting the android folder to build the app. This will cause the following error:

> Task :app:compileDebugJavaWithJavac FAILED
PROJECT_PATH/android/app/src/main/java/com/abdullahceylan/project_name/newarchitecture/MainApplicationReactNativeHost.java:109: error: cannot find symbol
                    ReactNativeConfig.DEFAULT_CONFIG,
                                     ^
  symbol:   variable DEFAULT_CONFIG
  location: interface ReactNativeConfig
PROJECT_PATH/android/app/src/main/java/com/abdullahceylan/project_name/MainActivity.java:76: error: method does not override or implement a method from a supertype
    @Override
    ^
Note: PROJECT_PATH/android/app/src/debug/java/com/abdullahceylan/project_name/ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors

FAILURE: Build failed with an exception.

To fix this issue, you need to run the android build with --template arg to use the tvOS template.

So instead of expo run:android use expo prebuild --template https://github.com/abdullahceylan/expo-template-bare-minimum-tvos first.

This will use the tvOS compatible template to build your app.

You also need to update your eas.json file to modify your prebuild command for EAS Builds:

"prebuildCommand": "prebuild --template https://github.com/abdullahceylan/expo-template-bare-minimum-tvos --no-install"

Problem 4

"Animated node with ID 2 already exists" error

This is due to the react-native-reanimated package. Confirm that you have added react-native-reanimated into resolutions section of package.json file and make sure that the dependencies and resolution section versions are matching:


  "dependencies": {
    .... other packages
    "react-native-reanimated": "2.10.0",
    .... other packages
  },
  "resolutions": {
    "react-native-reanimated": "2.10.0",
  }

Problem 5

React Navigation displays blank screen

If you are seeing a blank screen when you use React Navigation, probably you have wrapped the Navigation with a View. Try to remove that to solve the issue.

Before

<View>
  <Navigation />
</View>

After

<Navigation />

Problem 6

Error: could not connect to TCP port 5554: Connection refused

If you are getting this error when you try to run on Android, check with the service whose TCP is listening on 5554 + 1 = 5555. This service probably causing the automatic start of the Android emulator.

sudo lsof -i -P | grep LISTEN

Identify the process and kill that process with PID by running:

sudo kill -9 PID_NUMBER

Then everything should be fine.

Problem 7

Android emulator gives error Resetting for cold boot: emulation engine failed and exits

Run:

rm -vfr ~/.android/avd/[AVD name].avd/*.lock

@Bort-777
Copy link

Invariant Violation: requireNativeComponent: "ViewManagerAdapter_ExpoLinearGradient" was not found in the UIManager.

Faced some issues with iOS build, then resolved by fixing incorrect place of expo_patch_react_imports on Profile.lock. See correct place there (Expo docs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment