question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

expo-screen-orientation throws error

See original GitHub issue

🐛 Bug Report

Summary of Issue (just a few sentences)

When executing ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.ALL) or any other ScreenOrientation.OrientationLock on iOS or Android the following error is thrown:

“The method or property ScreenOrientation.lockAsync is not available on ios, are you sure you’ve linked all the native dependencies properly?”

Environment - output of expo diagnostics & the platform(s) you’re targeting

Expo CLI 3.21.5 environment info: System: OS: macOS 10.15.5 Shell: 3.2.57 - /bin/bash Binaries: Node: 12.6.0 - ~/.nvm/versions/node/v12.6.0/bin/node Yarn: 1.16.0 - /usr/local/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v12.6.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman IDEs: Android Studio: 3.6 AI-192.7142.36.36.6241897 Xcode: 11.5/11E608c - /usr/bin/xcodebuild npmPackages: expo: ~37.0.12 => 37.0.12 react: ~16.13.1 => 16.13.1 react-dom: ~16.13.1 => 16.13.1 react-native: https://github.com/expo/react-native/archive/sdk-37.0.0.tar.gz => 0.61.4 react-native-web: ~0.12.2 => 0.12.2 npmGlobalPackages: expo-cli: 3.21.5

Steps to Reproduce

useEffect(() => {
  ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.ALL)
})

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
perjanssoncommented, Jun 18, 2020

Hi @byCedric! The missing dependency array was a sloppy mistake, but that does not cause the issue for me since the error still occurs even after changing it to:

useEffect(() => {
  ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.ALL)
}, [])

I will have to see if I can produce this in a minimal project since this is now part of a pretty big Expo managed project and the error might be happening in combination with something else.

0reactions
perjanssoncommented, Aug 31, 2020

This all seems to have related to an outdated dependency to react-native, I was running version 0.37 and when updating to 0.38 this all just worked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ScreenOrientation - Expo Documentation
Screen Orientation is defined as the orientation in which graphics are painted on the device. For example, the figure below has a device...
Read more >
How to Change a Device's Screen Orientation using Expo in ...
To allow expo to handle changing the screen orientation we have to edit the app.json file. Go into your app.json file and delete...
Read more >
expo-screen-orientation - npm
Expo universal module for managing device's screen orientation. Latest version: 5.0.1, last published: 2 months ago.
Read more >
Expo-Screen-Orientation doesn't work with EAS BUILD - Reddit
I am using Expo-screen-orientation, managed flow and eas build. When I rotate in landscape it doesn't work after doing eas build in ios ......
Read more >
Expo ScreenOrientation.lockAsync() Problem - Stack Overflow
Expo ScreenOrientation. ... I'm building a React Native app using Expo. ... is causing an infinite loop or error when calling lockAsync.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found