asset.downloadAsync is not a function - SDK 35

Please provide the following:

  1. SDK Version: 35
  2. Platforms(Android/iOS/web/all): iOS & Android

I just upgraded from SDK 34 to 35 and I am getting the following error:

[Unhandled promise rejection: TypeError: asset.downloadAsync is not a function. (In 'asset.downloadAsync()', 'asset.downloadAsync' is undefined)]
- node_modules\expo-font\build\Font.js:99:10 in _loadSingleFontAsync$
etc

This is being called in my App.js:

import * as Font from 'expo-font'
import { Asset } from 'expo-asset'

 async _loadResourcesAsync() {
        await AsyncStorage.getAllKeys().then(keys => {
            console.log(keys)
        });

        try {
            await Promise.all([
                I18n.initAsync(),
                Font.loadAsync({
                    'Roboto': require('native-base/Fonts/Roboto.ttf'),
                    'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
                    'font awesome': require('@expo/vector-icons/FontAwesome'),
                })
            ])

        } catch (e) {
            errorOccurred(e);
        }

        this.setState({appIsReady: true})
    }

Has anyone run into this issue? I have tried deleting my node_modules and clearing my cache, deleting package-lock.json.

It seemed like this issue was opened before but not really solved: asset.downloadAsync is not a function

Looks like the code is trying to call downloadAsync on the result of require('native-base/Fonts/Roboto.ttf')

As a test, does the following work?

        Font.loadAsync({                                                                                                                                                                                    
          Roboto: 'https://github.com/google/fonts/raw/master/apache/roboto/Roboto-Regular.ttf',                                                                                                            
        })

Tried that, it didn’t work. But it gave me the idea of changing the Font Awesome one to:

'font awesome': require('native-base/Fonts/FontAwesome.ttf'),

Which got rid of the error.

1 Like