user3284707
user3284707

Reputation: 3351

Expo SDK38 upgrade - fontFamily "FontAwesome" is not a system font and has not been loaded through Font.loadAsync

Since I have upgraded to Expo SDK 38, I am getting this error when I start my app. I need to upgrade to SDK38 because Android will not let me publish at any less version.

This was working fine on SDK37, the only thing that I have changed is that I have upgraded all packages using expo upgrade, also there was an error error: unknown option --assetExts so I had to remove this from the app.json, which may be the cause. I changed assetExts to sourceExts which made it compile but maybe this is stopping the fonts working..

"packagerOpts": {         
    "assetExts": ["otf", "ttf"]    
},

enter image description here

I am following the example here of preloading the font in my App.js which is what all other answers that I can find are suggesting to do, but still getting the error.

I have also tried deleting my node_modules, package.json.lock and .expo folders, all which have not helped.

https://docs.expo.io/guides/preloading-and-caching-assets/#pre-loading-and-caching-assets

import { FontAwesome } from "@expo/vector-icons";

function cacheFonts(fonts) {
    return fonts.map((font) => Font.loadAsync(font));
}

const fontAssets = cacheFonts([FontAwesome.font]);
await Promise.all([...fontAssets]);

Upvotes: 1

Views: 669

Answers (1)

user3284707
user3284707

Reputation: 3351

Turns out this was a cache issue, the code was absolutely fine. I thought I had cleared everything but obviously not.

Deleted node_modules, package.json.lock again and npm installed and worked fine.

Upvotes: 2

Related Questions