expo: Release build Android APK won't show local image assets
Environment
Expo CLI 2.6.13 environment info:
System:
OS: macOS 10.14.2
Shell: 5.5 - /usr/local/bin/zsh
Binaries:
Node: 9.11.1 - ~/.anyenv/envs/ndenv/versions/v9.11.1/bin/node
Yarn: 1.9.4 - ~/.yarn/bin/yarn
npm: 6.0.0 - ~/.anyenv/envs/ndenv/versions/v9.11.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
expo: ^32.0.0 => 32.0.0
react: 16.5.0 => 16.5.0
react-native: https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz => 0.57.1
react-navigation: ^3.0.9 => 3.0.9
I’m using ExpoKit.
Steps to Reproduce
- Run
expo init
and choose react-navigation sample - Run
expo eject
and choose ExpoKit. - Run
expo publish
- Open
android
directory with Android Studio. - Set Signing setting for release build from
Project Structure > Signing
- Run app with
prodKernelRelease
build variants.
Expected Behavior
Images should be rendered.
This screenshot is taken in devKernelDebug
mode.
Actual Behavior
Images are not rendered. (Icons, and Image)
Images fetched through internet are properly rendered. However if it is a local image, it won’t show. In development mode, images are rendered properly.
Reproducible Demo
https://github.com/ykosaka-welyco/expo-signed-android-app-image-problem-reproduce
I created a demo keystore.jks
to sign production apk file. I noted the settings to use it in README.md.
Related issues
[0.57][ANDROID] Signed release do not show local assets images. https://github.com/facebook/react-native/issues/21309
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 33 (8 by maintainers)
@jdponomarev - making these changes to android/app/expo.gradle fixed the issue for me. Would you be able to give that a try on your project? If that solves the issue for you I’ll go ahead and put out a new version of expokit with the changes. Thanks 🙂
Hi @fcaride - please try this commit instead. (I’ve updated it in the previous post as well.) This change has fixed the issue that was originally reported and is now included in newly created ExpoKit projects. If that doesn’t fix things for you, could you open a new ticket with specific repro steps so that we can reproduce the exact issue you’re seeing? Thanks 🙂
Going to go ahead and close this now as the issue has been resolved.
I’m my case, it was all about gradle’s version.
I created a project on expo SDK v35 and ejected the project.
Android Studio asked me to update at some point and I silly accepted.
For Expo v35 after rolling back Gradle version to the following solved the issue : * Android Gradle Plugin Version - 3.3.2 * Gradle Version - 4.10.2
I’ve updated to SDK34, now it is not showing vector icons in released app.
I also had this problem. I fixed it by downgrade my build gradle from 3.2.1 to 3.1.3 and change the distributionUrl in the gradle-wrapper to gradle-4.4-all.zip
I had this issue Using Expo SDK 33 and Gradle 4.10.2.
The solution for me was to rewrite the doFirst hook in android/app/expo.gradle to
// Create dirs if they are not there (e.g. the “clean” task just ran) doFirst { if (!assetsDir.exists()) { assetsDir.mkdirs() } }
During the build process, the asset directory was being overwritten.
Hello,
I managed to correct my image display problem by removing this line from the app.json file. If it can help others 😃
Expo SDK 34
“assetBundlePatterns”: [ “** / *” ]
Regards,
@lilosir that probably means you’re running an older version of gradle. That commit fixes expo.gradle so that it works with gradle 4.10.2, which ships with newly ejected SDK 32 projects. For projects upgraded from an older SDK version, though, you should either leave expo.gradle alone (older version) or update both it AND all the rest of the android gradle/config files to match the SDK 32 templates.
Hope that helps!
@jdponomarev - apologies, looks like this is not fixed for ExpoKit projects. We’re looking into it now.
Hey guys, this is not fixed for me. I’m on freshly ejected 32 SDK and upgraded to expokit@32.0.6. I don’t see assets when I analyze the bundle in Android Studio.
They’re in bundledAssets after I publish the app as well as in Filesystem object when the app is loaded.
Any ideas?
This is now fixed on our build servers – please rebuild your app with
expo build:android
or, if you’re using ExpoKit, upgrade toexpokit@32.0.6
or later in order to get the fix.Hey, sorry for taking so long to look into this. 😕
Could you please try upgrading your
expokit
NPM package to32.0.6-rc.0
and seeing if the issue persists? 🙂Same issue here, I just have updated ExpoKit from SDK 32 to SDK 33 and now in release app bundle there are no images and vector icons.
Thanks for posting this. I spent 3 days trying to track this down. For future reference following the links in the forum are a little confusing, so here’s a synopsis:
Change the doFirst() method in android/app/expo.gradle to check if the assetsDir does not exist then make it.
I don’t know much about Gradle… but it seems making the directory regardless of whether it exists or not should work. I’d never have figured this out. This is still an issue using a fresh “expo init” followed by “expo eject” using SDK33.
@esamelson Sure thing! It worked 👍 Thanks!
@esamelson Hey, sorry, I didn’t get why you think that’s another issue. Could you please tell me which one you are speaking of? Because actually all the symptoms look pretty the same with this issue for me
FS.bundledAssets has all the assets, assetBundlePatterns are set and everything’s fine on emulator. But when I sign a production bundle, they’re not there
Thanks!