fontFamily 'Roboto_medium' is not a system font and has not been loaded through Exponent.Font.loadAsync.
See original GitHub issueMy environment:
"dependencies": {
"@expo/vector-icons": "^5.0.0",
"expo": "^18.0.4",
"link": "^0.1.5",
"native-base": "^2.2.0",
"react": "16.0.0-alpha.12",
"react-native": "https://github.com/expo/react-native/archive/sdk-18.0.1.tar.gz",
"react-native-vector-icons": "^4.2.0",
"react-navigation": "^1.0.0-beta.11"
}
I take a reference from official sample it just like:
import React from 'react';
import { Container, Header, Button, Text, Icon, Left, Right, Title, Body } from 'native-base';
export default class App extends React.Component {
render() {
return (
<Container>
<Header>
<Left>
<Button transparent>
<Icon name='menu' />
</Button>
</Left>
<Body>
<Title>I am Title Man</Title>
</Body>
<Right />
</Header>
<Button>
<Text>
Button
</Text>
</Button>
</Container>
);
}
}
It compiles well on my IOS emulator , but when i try it on Android emulator , it shows the error:
fontFamily ‘Roboto_medium’ is not a system font and has not been loaded through Exponent.Font.loadAsync.
-
If you intended to use a system font, make sure you typed the name correctly and that it is supported by your device operating system.
-
If this is a custom font, be sure to load it with Exponent.Font.loadAsync.
fontFamily ‘Roboto_medium’ is not a system font and has not been loaded through Exponent.Font.loadAsync.
-
If you intended to use a system font, make sure you typed the name correctly and that it is supported by your device operating system.
-
If this is a custom font, be sure to load it with Exponent.Font.loadAsync.
I try to find some solutions , it likes: 1.close running packager 2.run react-native link react-native-vector-icons 3.and run react-native start --reset-cache 4.Finally use react-native run-ios
It still can’t solve the issue , how can i fix it ?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:12 (2 by maintainers)
Top GitHub Comments
@motogod With expo you need to load custom fonts. Something like this
Hi,
Its been a long time i don’t use React Native any more.
Hope this code can help you.
Key point is the constructor and componentWillMount function
import React from ‘react’; import Expo from ‘expo’; import { StyleSheet, Text, View, StatusBar } from ‘react-native’; import { Container, Drawer, Header, Body, Left, Right, Button, Icon, Title, Footer, FooterTab, Content, Badge } from ‘native-base’;
import DrawerView from ‘./screens/DrawerView’;
export default class App extends React.Component { constructor() { super(); this.state = { isReady: false }; }
async componentWillMount() { await Expo.Font.loadAsync({ Roboto: require(“native-base/Fonts/Roboto.ttf”), Roboto_medium: require(“native-base/Fonts/Roboto_medium.ttf”), Ionicons: require(“@expo/vector-icons/fonts/Ionicons.ttf”) }); this.setState({ isReady: true }); }
closeDrawer = () => { console.log(‘closeDrawer click’); this.drawer._root.close() }; openDrawer = () => { console.log(‘openDrawer click’); this.drawer._root.open() };
//<View style={{ backgroundColor: ‘#227700’, height: 1000 }} /> render() { if (!this.state.isReady) { return <Expo.AppLoading />; }
return ( <Drawer ref={(ref) => { this.drawer = ref; }} content={<DrawerView />} backgroundColor= ‘#33FFAA’ onClose={() => this.closeDrawer()} >
<Container> <Header> <StatusBar backgroundColor="#008844" /> <Left> <Button transparent onPress={() => this.openDrawer()}> <Icon name='menu' /> </Button> </Left> <Body> <Title>Header</Title> </Body> <Right /> </Header> <Content> <Text> This is Content Section </Text> </Content> <Footer> <FooterTab> <Button full> <Text>Footer</Text> </Button> </FooterTab> </Footer> </Container> </Drawer>); } }
2018-01-17 18:05 GMT+08:00 githubmss notifications@github.com: