Recommended size splash screens crash Android app
See original GitHub issue🐛 Bug Report
Environment
Expo CLI 2.14.0 environment info:
System:
OS: macOS 10.14.4
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.15.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
expo: ^32.0.6 => 32.0.6
react: 16.5.1 => 16.5.1
react-native: https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz => 0.57.1
react-navigation: ^3.8.1 => 3.8.1
npmGlobalPackages:
expo-cli: 2.14.0
Target: Android
Steps to Reproduce
Running expo build:android --release-channel production
With the splash images of different Android DPIs sizes specified in the app.json
:
"splash": {
"image": "assets/splash.png",
"resizeMode": "cover",
"backgroundColor": "#FFFFFF"
},
"android": {
"versionCode": 1,
"package": "com.me.myApp",
"splash": {
"mdpi": "assets/splash/mdpi/splash.png",
"hdpi": "assets/splash/hdpi/splash.png",
"xhdpi": "assets/splash/xhdpi/splash.png",
"xxhdpi": "assets/splash/xxhdpi/splash.png",
"xxxhdpi": "assets/splash/xxxhdpi/splash.png"
}
}
Of the recommended sizes and file size:
mdpi: 1242x2436 (278 KB),
hdpi: 1863x3654 (146 KB),
xhdpi: 2484x4872 (438 KB),
xxhdpi: 3726x7308 (846 KB),
xxxhdpi: 4968x9744 (1.34 MB)
Successfully produces an apk
Expected Behavior
It should run fine
Actual Behavior
It crashes when it is run on a xxxhdpi
Android device with the following error
04-16 23:21:52.037 27573 27573 D AndroidRuntime: Shutting down VM
04-16 23:21:52.038 27573 27573 E AndroidRuntime: FATAL EXCEPTION: main
04-16 23:21:52.038 27573 27573 E AndroidRuntime: Process: com.me.myApp, PID: 27573
04-16 23:21:52.038 27573 27573 E AndroidRuntime: java.lang.RuntimeException: Canvas: trying to draw too large(108918432bytes) bitmap.
04-16 23:21:52.038 27573 27573 E AndroidRuntime: at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:229)
04-16 23:21:52.038 27573 27573 E AndroidRuntime: at android.view.RecordingCanvas.drawBitmap(RecordingCanvas.java:101)
04-16 23:21:52.038 27573 27573 E AndroidRuntime: at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:545)
04-16 23:21:52.038 27573 27573 E AndroidRuntime: at android.widget.ImageView.onDraw(ImageView.java:1360)
04-16 23:21:52.038 27573 27573 E AndroidRuntime: at android.view.View.draw(View.java:21882)
It is saying that my splash image size is 108.918432 MB
large when it actually is just 1.34MB
However it runs fine when I scale it back from the default 1242x2436
but I get the following warning when building it
[dpi: provided (expected)] mdpi: 320x628 (1242x2436), hdpi: 480x942 (1863x3654), xhdpi: 640x1256 (2484x4872), xxhdpi: 960x1884 (3726x7308), xxxhdpi: 1280x2512 (4968x9744)
Reproducible Demo
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Splash screens - Android Developers
Splash Screen dimensions · Branded image: This should be 200×80 dp. · App icon with an icon background: This should be 240×240 dp,...
Read more >Splash Screen in Android - ProAndroidDev
Splash screen is a screen that loads when you launch an app. When you first open your application, a loading screen, also known...
Read more >android splash screen sizes for ldpi,mdpi, hdpi, xhdpi displays
xlarge screens are at least 960dp x 720dp · large screens are at least 640dp x 480dp · normal screens are at least...
Read more >A Comprehensive Guide to Android 12's Splash Screen API
It will cause the app to crash. The default Android Studio templates always add this attribute to entry activities so look out for...
Read more >Attempt to add splash screen crashes app and results in two ...
Also, I get TWO launch icons on my test device when the splash screen code is in the manifest, a Samsung Galaxy S6...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It worked. I modified the app.json, and I resized the splash:
if you are on bare workflow, as instructed you can use
npx expo-splash-screen
to install the splash screen for native android/ios. Once installed to solve the issue, just use Image Bake to scale down the splash and then paste thedrawable-mdpi, ..., drawable-xxxhdpi
tores
subfolder of your android native app.