Android standalone app crashing on Android X
Problem
Hi expo team, I did update SDK yesterday. (35 to 36). Android build does not work on android x versions. The application gives error after splash screen. "Application keep stopping". and no error. I'm just getting unsafe lifecycle methods warning from GridList and Hyperlink packages. I uninstalled and tried these packages, but the problem persists. But there is a detail; The application opens smoothly on first installation. But if you close it through the task manager it won't open again. Expo CLI 3.11.1 environment info: System: OS: macOS 10.15.1 Shell: 5.7.1 - /bin/zsh Binaries: Node: 10.17.0 - /usr/local/opt/node@10/bin/node Yarn: 1.19.1 - /usr/local/bin/yarn npm: 6.11.3 - /usr/local/opt/node@10/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman IDEs: Android Studio: 3.5 AI-191.8026.42.35.5900203 Xcode: 11.1/11A1027 - /usr/bin/xcodebuild npmPackages: expo: ^36.0.0 => 36.0.0 react: 16.9.0 => 16.9.0 react-native: https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz => 0.61.4 react-navigation: ^4.0.10 => 4.0.10 npmGlobalPackages: expo-cli: 3.11.1
Error Output
error after splash screen. "Application keep stopping". and no error. I'm just getting unsafe lifecycle methods warning from GridList and Hyperlink packages.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix Android App Crash on Android X After SDK Update
The application is likely crashing due to incompatibilities introduced in the Expo SDK update from 35 to 36, particularly with the use of deprecated lifecycle methods in the GridList and Hyperlink packages. These methods may not be fully compatible with Android X, leading to instability when the app is reopened after being closed via the task manager.
Awaiting Verification
Be the first to verify this fix
- 1
Update Dependencies
Ensure all dependencies are updated to their latest versions that are compatible with Expo SDK 36. This includes checking for updates to GridList and Hyperlink packages.
bashnpm update gridlist hyperlink - 2
Migrate to Safe Lifecycle Methods
Refactor the code to replace any unsafe lifecycle methods used in GridList and Hyperlink components with safe alternatives. This may involve using componentDidMount, componentDidUpdate, and componentWillUnmount instead of deprecated methods.
javascriptcomponentDidMount() { /* Safe initialization code */ } - 3
Enable Android X Support
Make sure that your project is configured to support Android X. This can be done by adding the following to your `android/gradle.properties` file: `android.useAndroidX=true` and `android.enableJetifier=true`.
bashecho 'android.useAndroidX=true' >> android/gradle.properties && echo 'android.enableJetifier=true' >> android/gradle.properties - 4
Clear Build Cache
Clear the build cache to ensure that no old artifacts are causing issues. Run the following commands in your project directory.
bashcd android && ./gradlew clean - 5
Rebuild the Application
After making the above changes, rebuild the application using Expo CLI. This will ensure that all changes are compiled correctly.
bashexpo build:android
Validation
To confirm the fix worked, install the updated application on an Android device running Android X. Verify that the app launches successfully after the splash screen and that it can be reopened after being closed via the task manager without crashing.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep