RN version: “0.70.5”
Expo sdk version: “^47.0.0”
EAS cli version: “3.17.1”
I add a new local image into my assets/images/ directory along with dozens of others that have worked for years and the new image will no load in Android, both device and simulator. iOS works fine. I try building/running the app using expo run:android
, react-native run-android
, and also by build a development client and running the dev client server. All the same. I’ve tried with png, jpg, and webp ( which is what I really want ) and all the same. LogCat shows no errors. The onError
callback of ImageBackground returns this
Unexpected HTTP code Response{protocol=h2, code=403, message=, url=https://classic-assets.eascdn.net/~assets/d6d0c23ea2865f5380f950ad185c4787}
however I see the same on iOS and those images load correctly. I’m attempting to load like this but I’ve also tried using require.
import React, { useLayoutEffect } from 'react'
import { ImageBackground, StyleSheet, View } from 'react-native'
import { useNavigation } from '@react-navigation/native'
import OnboardingBg from '../../../../assets/images/backgrounds/onboarding_bg.webp'
export default function GetStarted() {
const navigation = useNavigation()
useLayoutEffect(() => {
navigation.setOptions({
headerShown: false,
})
})
return (
<View style={StyleSheet.absoluteFillObject}>
<ImageBackground
source={OnboardingBg}
resizeMode="cover"
style={StyleSheet.absoluteFillObject}
onError={(e) => console.log('E', e.nativeEvent.error)}
/>
</View>
)
}
Images do show up in production builds though. I’ve tried bundling assets in debug builds as well. No difference. Snapshot of build.gradle deps
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
// If your app supports Android versions before Ice Cream Sandwich (API level 14)
// All fresco packages should use the same version
if (isGifEnabled || isWebpEnabled) {
implementation 'com.facebook.fresco:fresco:2.6.0'
implementation 'com.facebook.fresco:imagepipeline-okhttp3:2.6.0'
}
if (isGifEnabled) {
// For animated gif support
implementation 'com.facebook.fresco:animated-gif:2.6.0'
}
if (isWebpEnabled) {
// For webp support
implementation 'com.facebook.fresco:webpsupport:2.6.0'
if (isWebpAnimatedEnabled) {
// Animated webp support
implementation 'com.facebook.fresco:animated-webp:2.6.0'
}
}