expo-asset images missing, no cloudfront access?

I am working on an app for Android using the Unimodules
Everything was going fine, until recently. I have a bunch of images that are required, but when I use the Asset from expo-asset, they stop being loaded. As far as I seen, looks like the program is unable to retrieve them from the CloudFront
But the weird part is that this was not happening until recently. Images where being fetched from the devices, as I would have expected. Also, when I disable the Asset, they work fine again, I guess the system falls back to the React Native way of handling images.
I feel like there is something I don’t understand about how expo unimodules manages Assets. It always fetches them from an online source? even when using require?
I also seen that you can config the App.json->assetBundlePatterns to bundle images that match a “pattern” into the App… ¿But maybe that only works when the App is ejected or final build is done?
And another thing, the first time the images stopped working, I noticed that something had changed, a new unimodule module was added on an update, “unimodules-app-loader”, so I tried excluding it in the build.gradle (like “addUnimodulesDependencies([exclude: [”) and with that, the images started working locally again.
But then, yesterday I updated something and now the images are not working again.
This all happened in this past two weeks
I wish to know if there is a way to avoid using remote assets altogether without losing the Asset package (I need it to use with expo-gl, texImage2D)
Thanks for your attention, I hope this post is not too much a mess and is understandable
Best Regards,
Paco

hi there, can you please provide a minimal reproducible example? indeed it’s a bit difficult to parse the situation you have from the text provided :slight_smile:

Yeah, sorry about that, I’ll try to do an example that illustrates this more clearly

So I created a new project and that was harder than it was before. So much updates this days…
So, for starters I am using react 0.61.5, because 0.62 I couldn’t get it working properly with unimodules for some reason. But my original project is in 0.61.5, so… yeah

So I did (without yarn)

  • npx react-native init AssetUnimoduleInestability --version 0.61.5
  • npm install react-native-unimodules
  • then configured all the unimodule stuff, MainActivity, the gradles things etc
  • npm install fbemitter (what? well, because some packs asked for expo-update, and npm got expo-updates@0.0.1-rc.3 and turns out that in that version there is no declaration for fbemitter dependency, but apparently it does really depend on fbemitter, so I just… manually added it… by the way, 0.0.1-rc.1 does declare the fbemitter dependency)
  • anyway, back on track, I created a simple app that displays image (screenshot because writing the code with good formatting is annoying right now
    There is a github for this

And npx react-native run-android from here
After that, commenting and uncommenting the Asset import gives me differents uri for the image. As far as I understand that is intended. I get this ones

with Asset
https://d1wp6m56sqw74a.cloudfront.net/~assets/eb62345013f8a7de17984fd7a1d238f8

without Asset
http://192.168.0.7:8081/assets/icono.png?platform=android&hash=eb62345013f8a7de17984fd7a1d238f8

So the one from cloudfront does not work. I don’t know if I am miss configuring something, or cloudfront doesn’t serve stuff to my region or what. But despite that, I do want the images of my app to be served on the apk, and the assetBundlePatterns don’t seem to work, or I am using it wrong


So I found a hacky solution for now, and it’s to set back the resolver to default, after importing the Asset… I don’t know, it’s enough for me, but I have this feeling that I am not understanding a lot of what’s happening on this framework
Hacky →


Again, thanks for your time

hi there! sorry for the hassle. it looks like react-native-unimodules@0.8.1 was set to the latest version a bit prematurely… if you try again you should get react-native-unimodules@0.7.0 and this should work as expected

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.