Quick Fix: In your eas.json
file, modify the production
section to specify the build type as "apk"
.
The Problem:
Expo developers recently shifted from expo build:android -t apk to eas build -p android –profile preview for building Android APKs using Expo Application Services (EAS). However, this shift resulted in an AAB file being generated instead of an APK, leading to installation and crashing issues on Android devices. The newly added eas.json file’s configuration seems to be correct, but the resulting APK behaves abnormally, closing immediately upon launch with crash alerts. The task is to identify the issue in the eas.json file or underlying build process to resolve the APK generation and installation problems.
The Solutions:
Solution 2: Create an EAS JSON file and Build APK
- Create an
eas.json
file in the project directory with the following content:
{
"build": {
"preview": {
"android": {
"buildType": "apk"
}
},
"production": {}
},
"cli": {
"version": ">= 0.52.0"
}
}
- Run the following command to build the APK:
eas build -p android --profile preview
This should build the APK correctly and allow you to install and run the app without crashing.
Solution 4: Null Value From expo-constant and sentry causing crash
The problem arises due to the usage of a value from expo-constant
, which results in a null
value. This leads to the app crashing. The issue is caused by the upgrade to EAS build, which has moved the needed value to expo-device
.
To resolve this, use expo-device
to access the required value. Additionally, consider removing sentry
temporarily to check if it is the cause of the instant crash when opening the app.