question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android standalone doesn't load images

See original GitHub issue

Hey everyone, I’ve been stuck on an android standalone build issue for a couple days now. Would really appreciate any tips. I’ve read through all the similar issue reports but those fixes don’t seem to help anymore.

This is how I’ve been loading assets (works fine in Expo and iOS standalone) this.backgroundTexture = await ExpoTHREE.loadAsync(Asset.fromModule(require('../assets/textures/white_marble.png')));

On android standalone, the image just shows up blank. App doesn’t crash though, like other devs reported in 2019.

I also tried: this.backgroundTexture = await ExpoTHREE.loadAsync("https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png");

but no luck! Url also doesn’t load.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
jwrubelcommented, Nov 23, 2020

I ran in to this issue as well in Android release variants. What ended up working for me is [this modification] - change the extension of the image to .xpng (otherwise on Android, it gets moved to the drawables folder instead of raw, and expo loader expects them in raw.

With this change in place, the following code should work (using your example above):

const assetFromMod = Asset.fromModule(require('../assets/textures/white_marble.xpng'))
if (assetFromMod.type === 'xpng') assetFromMod.type = 'png'; // just in case, switch back to .png
await assetFromMod.downloadAsync()
let tex = new TextureLoader().load(assetFromMod.localUri);

you should then be able to use tex with any material. This change also works with iOS too, so you don’t need any platform specific logic.

There are a few issues filed with the main expo/expo repo related to this so hopefully is a temporary workaround.

0reactions
jwrubelcommented, Oct 20, 2022

I’m not sure how much I will be able to help with that error. I don’t have any experience with debugging Android - I only found the trick with changing extensions for images after many hours of searching and it worked for me so I thought I would share. In your adb logcat I notice libexpo-gl.so not found on /data/data/com.jackz_sparoow.SampleApp/lib-main and that seems like it could be related. If your app can’t load libexpo-gl or doesn’t have it linked you would have a lot of problems with texture loading. But again I have very little experience with debugging these sorts of problems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Picasso: Image doesn't load when I add NetworkPolicy. ...
The code works fine when I am online. When I add .networkPolicy(NetworkPolicy.OFFLINE) to display the image offline the image doesn't show at ...
Read more >
How to Fix Images Not Loading in Chrome
When Chrome doesn't display images on a site, switch to another web browser on your computer and see if you can load the...
Read more >
Why Can't I See My Pictures in My Gallery, How to Fix?
Part 1. Why Android Gallery Not Showing Pictures? · The images are saved as .nomedia file · The caches cause the issue.
Read more >
Troubleshoot known issues with Android Emulator
This page lists known issues, workarounds, and troubleshooting tips for the Android Emulator. If you encounter an issue not listed here or ...
Read more >
[expo-gl][Android][standalone] gl.texImage2D doesn't ...
In Android standalone app asset resolves to local uri with protocol asset:// and gl.texImage2D(...) doesn't render image for such uri. I assume that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found