Closed uakhundz closed 3 years ago
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.
As a quick fix, what also ended up working was removing assetBundlePatterns
from app.json
entirely (not just an empty array). This fixed it in the short term but I will be trying the solution above because I do want to properly bundle the assets and not have platform specific implementations.
@jwrubel As you mentioned we need to change extension of image from .png
to .xpng
is that the same of .jpg
images ?
like change it from .jpg
to .xjpg
or convert all images to .xpng
?
@jack-sparroow That's correct. I changed both .png
and .jpgto
.xpngand
.xjpgso that they end up moved into the correct folder on Android. This prevents expo from moving them into an inaccessible folder. I only have png and jpg types in my project but I think this change would be required for any file with an
image/` mime type.
I also haven't updated my underlying expo* library versions in a while so it's possible this isn't an issue in later builds, but this change worked for me.
@jwrubel I have changed the file names from .jpg, .png
to .xjpg, .xpng
. But Animations are still not getting loaded instead I got error in adb logcat
2022-10-20 11:25:50.913 5047-5301/com.jackz_sparoow.SampleApp D/libMEOW: applied 0 plugin for [com.jackz_sparoow.SampleApp].
2022-10-20 11:25:50.914 5047-5047/com.jackz_sparoow.SampleApp D/SoLoader: libexpo-gl.so not found on /data/data/com.jackz_sparoow.SampleApp/lib-main
2022-10-20 11:25:50.914 5047-5047/com.jackz_sparoow.SampleApp D/SoLoader: libexpo-gl.so found on /data/app/com.jackz_sparoow.SampleApp-XuiBj4ZaFooSQJhOWwsCMg==/lib/arm
2022-10-20 11:25:50.914 5047-5047/com.jackz_sparoow.SampleApp D/SoLoader: Not resolving dependencies for libexpo-gl.so
2022-10-20 11:25:50.922 5047-5301/com.jackz_sparoow.SampleApp D/Surface: Surface::connect(this=0xc25b1000,api=1)
2022-10-20 11:25:50.922 5047-5301/com.jackz_sparoow.SampleApp I/BufferQueueProducer: [SurfaceTexture-0-5047-0](this:0xc10d6000,id:0,api:1,p:5047,c:5047) connect(P): api=1 producer=(5047:com.jackz_sparoow.SampleApp) producerControlledByApp=true
2022-10-20 11:25:50.927 5047-5301/com.jackz_sparoow.SampleApp W/Gralloc3: allocator 3.x is not supported
2022-10-20 11:25:50.931 5047-5301/com.jackz_sparoow.SampleApp E/ion: ioctl c0044901 failed with code -1: Invalid argument. ----> Error
2022-10-20 11:25:51.062 5047-5076/com.jackz_sparoow.SampleApp I/.SampleApp: NativeAlloc concurrent copying GC freed 24773(1214KB) AllocSpace objects, 0(0B) LOS objects, 24% free, 18MB/24MB, paused 340us total 183.623ms
2022-10-20 11:25:51.091 5047-5189/com.jackz_sparoow.SampleApp I/ReactNativeJS: 60
2022-10-20 11:25:51.175 5047-5191/com.jackz_sparoow.SampleApp E/.SampleApp: Invalid ID 0x00000000. ----> Error
2022-10-20 11:25:51.175 5047-5191/com.jackz_sparoow.SampleApp E/FileSystemModule: Resource ID #0x0 ----> Error
2022-10-20 11:25:51.232 5047-5126/com.jackz_sparoow.SampleApp I/System.out: [socket]:check permission begin!
2022-10-20 11:25:51.233 5047-5127/com.jackz_sparoow.SampleApp I/System.out: [socket]:check permission begin!
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.
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.