(1)在settings.gradle中添加以下内容
include
‘:react-native-baidu-map’
project(‘:react-native-baidu-map’)
.projectDir =
new File(settingsDir,
‘…/node_modules/react-native-baidu-map/android’)
(2)在build.gradle中添加:
compile project(':react-native-baidu-map')
(3) 修改MainApplication.Java 文件
添加:new BaiduMapPackage(getApplicationContext())
例如:
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new BaiduMapPackage(getApplicationContext())
);
}
(4) 修改AndroidMainifest.xml 文件
此文件有2处需要配置:
1)配置各种权限
2)添加com.baidu.lbsapi.API_KEY
完整权限配置:
<uses-permission android:name=“android.permission.ACCESS_COARSE_LOCATION”>
</uses-permission>
<uses-permission android:name=“android.permission.ACCESS_FINE_LOCATION”>
</uses-permission>
<uses-permission android:name=“android.permission.ACCESS_WIFI_STATE”>
</uses-permission>
<uses-permission android:name=“android.permission.INTERNET” />
<uses-permission android:name=“android.permission.SYSTEM_ALERT_WINDOW”/>
<uses-permission android:name