I built eas build -p android –profile production(with Expo SDK 51, The build was successful without any problems). Then, I downloaded apk into physical device. When install and open it, the app crashes after showing splash screen.
There’s nothing wrong with the simulator and the expo go app
So I connected the physical device to the PC and tried again as below
1. eas build -p android --profile production --clear-cache
2. adb install -r MyApp.apk
3. adb logcat
But the app crashes after showing splash screen again.
I found exceptions in Logcat’s log as below.
06-18 15:16:23.359 1455 3526 W WindowManager: Exception thrown during dispatchAppVisibility Window{b491ce8 u0 com.myApp.MyApp/com.myApp.MyApp.MainActivity EXITING}
06-18 15:35:37.566 1455 1567 W PackageManager: java.lang.IllegalArgumentException: Unable to get package com.myApp.MyApp
06-18 15:35:38.323 18370 18370 W Finsky : [2] aegq.b(126): STU: Failed to get storage stats for package 'com.myApp.MyApp' (1601: Error getting stats: android.content.pm.PackageManager.NameNotFoundException)
06-18 15:57:18.002 25857 25946 W GOS:PackageUtil: isPackageInstalledAsUser(). Exception: android.content.pm.PackageManager$NameNotFoundException: com.myApp.MyApp
06-18 15:57:53.221 1455 2981 W WindowManager: Exception thrown during dispatchAppVisibility Window{1ccb0a5 u0 com.myApp.MyApp/com.myApp.MyApp.MainActivity EXITING}
06-18 15:58:02.730 1455 6310 E AppOps : java.lang.SecurityException: Specified package "com.myApp.MyApp" under uid -1 but it is not
06-18 16:06:54.320 26999 26999 E AppButtonsPrefCtl: Exception when retrieving package:com.myApp.MyApp
06-18 16:06:54.320 26999 26999 E AppButtonsPrefCtl: android.content.pm.PackageManager$NameNotFoundException: com.myApp.MyApp
06-18 16:06:54.537 18370 18612 W ResourcesManager: java.io.IOException: Failed to load asset path /data/app/~~DvIivdyMBKmqze5UOR38yA==/com.myApp.MyApp-djdb_-FbcxNuzhRd3BN9Dw==/base.apk
Can someone tell or direct or advice me?
Here is my app.json, eas.json and package.json
app.json
{
"expo": {
"name": "MyApp",
"slug": "MyApp",
"platforms": [
"ios",
"android"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"scheme": "myapp",
"userInterfaceStyle": "automatic",
"splash": {
"image": "./assets/images/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.myApp.MyApp",
"buildNumber": "1.0.0"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/images/icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.myApp.MyApp",
"versionCode": 1
},
"web": {
"bundler": "metro",
"output": "static",
"favicon": "./assets/images/favicon.png"
},
"plugins": [
"expo-router",
"expo-font"
],
"experiments": {
"typedRoutes": true,
"tsconfigPaths": true
},
"extra": {
"router": {
"origin": false
},
"eas": {
"projectId": "xxxx-xxxx-xxxx-xxxx-xxxx"
}
}
}
}
eas.json
{
"cli": {
"version": ">= 9.2.0"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"distribution": "internal"
},
"production": {
"android": {
"buildType": "apk"
}
}
},
"submit": {
"production": {}
}
}
package.json
{
"name": "myApp",
"main": "expo-router/entry",
"version": "1.0.0",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"test": "jest --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/vector-icons": "^14.0.0",
"@react-native-async-storage/async-storage": "1.23.1",
"@react-native-community/datetimepicker": "8.0.1",
"@react-native-picker/picker": "2.7.5",
"@react-navigation/native": "^6.0.2",
"@supabase/supabase-js": "^2.43.1",
"@tanstack/react-query": "^5.36.0",
"expo": "^51.0.14",
"expo-constants": "~16.0.2",
"expo-device": "~6.0.2",
"expo-font": "~12.0.7",
"expo-linking": "~6.3.1",
"expo-notifications": "~0.28.9",
"expo-router": "~3.5.16",
"expo-splash-screen": "~0.27.5",
"expo-status-bar": "~1.12.1",
"expo-system-ui": "~3.0.6",
"expo-web-browser": "~13.0.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.51.3",
"react-native": "0.74.2",
"react-native-elements": "^3.4.3",
"react-native-modal-datetime-picker": "^17.1.0",
"react-native-safe-area-context": "4.10.1",
"react-native-screens": "3.31.1",
"react-native-select-dropdown": "^4.0.1",
"react-native-url-polyfill": "^2.0.0",
"react-native-web": "~0.19.6"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@types/react": "~18.2.45",
"jest": "^29.2.1",
"jest-expo": "~51.0.1",
"react-test-renderer": "18.2.0",
"typescript": "~5.3.3"
},
"private": true
}
2
Answers
This issue was due to environmental variables. It was caused by the failure to load environmental variables in the build. Make sure the environmental variables are loaded properly.
I have same issue with my project EXPO SDK 51. Everything works well on Expo Go, but the version from production is crashing.