I am facing undefined is not an object issue after following the steps mentions in installation guide. I have attached log file
logs.txt
Steps followed:
$ node -v
v8.9.3
$ npm -version
5.5.1
android version - 27
package.json
{
"name": "SampleMap",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"@mapbox/react-native-mapbox-gl": "^6.0.3-rc1",
"react": "^16.2.0",
"react-native": "^0.52.1"
},
"devDependencies": {
"babel-jest": "22.1.0",
"babel-preset-react-native": "4.0.0",
"jest": "22.1.4",
"react-test-renderer": "16.2.0"
},
"jest": {
"preset": "react-native"
}
}
app.js
import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
import Mapbox from '@mapbox/react-native-mapbox-gl';
Mapbox.setAccessToken('key');
export default class App extends Component<{}> {
render() {
return (
zoomLevel={15}
centerCoordinate={[11.256, 43.770]}
style={styles.container}>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
Could you also post your settings.gradle?
Also did you add this to your MainApplication.java?
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RCTMGLPackage(),
);
}
This is my settinngs.gradle
`
rootProject.name = 'SampleMap'
include ':app'
include ':mapbox-react-native-mapbox-gl'
project(':mapbox-react-native-mapbox-gl').projectDir = new File(rootProject.projectDir, '../node_modules/@mapbox/react-native-mapbox-gl/android/rctmgl')
`
Thank you @nitaliano.
Sorry I missed adding above code, it solved my issue.
Thank you very much
Most helpful comment
Could you also post your settings.gradle?
Also did you add this to your
MainApplication.java?