运行React Native Maps应用程序时出错

时间:2018-09-21 18:50:53

标签: react-native

enter image description here

我的代码:App.js

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import CurrentPosition from './currentPosition'
import Tracker from './watchPosition'

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
  android:
    'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

type Props = {};
export default class App extends Component<Props> {
  render() {
    return (
      <View style={styles.container}>
        <Mapview style={styles.map}
        region={{
          latitude:59.329,
          longitude:18.068,
          latitudeDelta:0.1,
          longitudeDelta:0.1
                }}
                >
                </Mapview>
        <Tracker />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    position:'absolute',
    top:0,
    left:0,
    bottom:0,
    right:0,
    justifyContent:'flex-end',
    alignItems:'center'
  },
  map:{
     position:'absolute',
      top:0,
    left:0,
    bottom:0,
    right:0
  }
});

为了测试目的,这些值已针对纬度和经度进行了硬编码。尽管当我尝试运行该应用程序时,以下错误仍然存​​在,如图所示

错误: 无法在设备上安装该应用,请阅读上面的错误以获取详细信息。 确保您正在运行Android模拟器或已连接设备,并且 设置您的Android开发环境: https://facebook.github.io/react-native/docs/getting-started.html

1 个答案:

答案 0 :(得分:0)

转到./node_modules/react-native-maps/build.gradle 然后执行此操作:

implematition -> compile
compileOnly -> provided