expo: Current activity not found. Make sure to call this method while your application is in foreground.

Summary

Using expo-splash-screen and SplashScreen.preventAutoHideAsync() throws many errors in production builds.

I call preventAutoHideAsync first thing in App.js. The error message is Current activity not found. Make sure to call this method while your application is in foreground..

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

bare

What platform(s) does this occur on?

Android

SDK Version (managed workflow only)

42.0.5

Environment

Expo CLI 4.7.3 environment info: System: OS: macOS 11.5.1 Shell: 5.8 - /bin/zsh Binaries: Node: 16.9.1 - /opt/homebrew/bin/node Yarn: 1.22.11 - /opt/homebrew/bin/yarn npm: 7.21.1 - /opt/homebrew/bin/npm Watchman: 2021.09.13.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.2 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4 Android SDK: API Levels: 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 31.0.0 System Images: android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs ARM 64 v8a, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play ARM 64 v8a, android-30 | Google Play Intel x86 Atom, android-S | Google Play ARM 64 v8a Android NDK: 20.1.5948944 IDEs: Android Studio: 4.2 AI-202.7660.26.42.7486908 Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild npmPackages: expo: ^42.0.5 => 42.0.5 react: 17.0.1 => 17.0.1 react-native: 0.64.2 => 0.64.2 Expo Workflow: bare

Reproducible demo or steps to reproduce from a blank project

SplashScreen.preventAutoHideAsync()
  .then(() => console.log(`SplashScreen.preventAutoHideAsync() succeeded`))
  .catch(e => Bugsnag.notify(e))

Called first thing in App.js

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 15 (5 by maintainers)

Most upvoted comments

I am using expo SDK 44 (managed workflow) and still getting this error. Any solution yet ?

Here’s my package.json dependencies:

 ...
 "dependencies": {
     "@babel/preset-typescript": "^7.16.7",
     "@react-native-async-storage/async-storage": "~1.15.0",
     "@react-native-community/datetimepicker": "4.0.0",
     "@react-native-community/masked-view": "0.1.10",
     "@react-native-community/netinfo": "7.1.3",
     "@react-navigation/bottom-tabs": "^5.11.11",
     "@react-navigation/material-top-tabs": "^5.3.15",
     "@react-navigation/native": "^5.9.4",
     "@react-navigation/stack": "^5.14.5",
     "axios": "^0.19.0",
     "expo": "^44.0.0",
     "expo-apple-authentication": "~4.1.0",
     "expo-asset": "~8.4.6",
     "expo-auth-session": "~3.5.0",
     "expo-blur": "~11.0.0",
     "expo-camera": "~12.1.2",
     "expo-clipboard": "~2.1.0",
     "expo-constants": "~13.0.1",
     "expo-device": "~4.1.0",
     "expo-facebook": "~12.1.0",
     "expo-image-picker": "~12.0.1",
     "expo-linear-gradient": "~11.0.3",
     "expo-linking": "~3.0.0",
     "expo-notifications": "~0.14.0",
     "expo-random": "~12.1.1",
     "expo-splash-screen": "~0.14.1",
     "expo-updates": "~0.11.6",
     "html-entities": "^1.2.1",
     "lodash": "^4.17.21",
     "moment": "^2.24.0",
     "prop-types": "^15.7.2",
     "react": "17.0.1",
     "react-dom": "17.0.1",
     "react-native": "0.64.3",
     "react-native-autoheight-webview": "^1.3.2",
     "react-native-custom-qr-codes-expo": "^2.2.0",
     "react-native-easy-toast": "^1.2.0",
     "react-native-gesture-handler": "~2.1.0",
     "react-native-keyboard-aware-scroll-view": "^0.9.1",
     "react-native-loading-placeholder": "0.0.6",
     "react-native-progress": "^4.1.2",
     "react-native-reanimated": "~2.3.1",
     "react-native-responsive-fontsize": "^0.2.1",
     "react-native-safe-area-context": "3.3.2",
     "react-native-screens": "~3.10.1",
     "react-native-snap-carousel": "^3.8.0",
     "react-native-status-bar-height": "^2.4.0",
     "react-native-svg": "12.1.1",
     "react-native-tab-view": "^2.16.0",
     "react-native-text": "^0.2.0",
     "react-native-web": "0.17.1",
     "react-native-webview": "11.15.0",
     "react-navigation-transitions": "^1.0.12",
     "react-placeholder": "^3.0.2",
     "react-redux": "^7.1.0",
     "redux": "^4.0.1",
     "redux-define": "^1.1.1",
     "redux-enhancer-react-native-appstate": "^0.3.1",
     "redux-persist": "^5.10.0",
     "redux-persist-expo-filesystem": "^2.0.0",
     "redux-thunk": "^2.3.0",
     "sentry-expo": "^4.0.0"
   },
   "devDependencies": {
     "babel-plugin-transform-remove-console": "^6.9.4",
     "babel-preset-expo": "9.0.2",
     "copyfiles": "^2.3.0",
     "jest": "^26.6.3",
     "jest-expo": "^44.0.0",
     "metro-react-native-babel-preset": "^0.64.0",
     "react-native-dotenv": "^0.2.0",
     "react-test-renderer": "^16.10.2",
     "reactotron-react-native": "1.14.0",
     "reactotron-redux": "1.13.0"
   },
 ...

Yeap. It is happening in SDK 46, managed.