hufeng / BaiduMapKit

百度地图的React-Native Android版本
MIT License
223 stars 61 forks source link

在RN 0.25中报告错误,同时RN的api应该是变了。 #13

Open bluebird88 opened 8 years ago

bluebird88 commented 8 years ago

MainActivity中注册变成了:

protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),new BaiduMapReactPackage(this)
    );
}

编译过程中显示一大堆unknown source,类似:

Unknown source file : warning: Ignoring InnerClasses attribute for an anonymous inner class Unknown source file : (com.baidu.platform.comapi.b) that doesn't come with an Unknown source file : associated EnclosingMethod attribute. This class was probably produced by a Unknown source file : compiler that did not target the modern .class file format. The recommended Unknown source file : solution is to recompile the class from source, using an up-to-date compiler Unknown source file : and without specifying any "-target" type options. The consequence of ignoring 。。。。。 ,最后编译完毕,部署到真机或者模拟器,点击都会立即显示应用无法响应;logcat中显示一大堆错误,其中一个好像是初始化过程中的错误:

05-11 15:19:14.857: I/ReactNativeJS(18155): Running application "MyProject" with appParams: {"initialProps":{},"rootTag":1}. DEV === true, development-level warning are ON, performance optimizations are OFF 05-11 15:19:14.879: W/ReactNativeJS(18155): Warning: ReactNative.createElement is deprecated. Use React.createElement from the "react" package instead. 05-11 15:19:14.901: E/unknown:React(18155): Exception in native call from JS 05-11 15:19:14.901: E/unknown:React(18155): java.lang.IllegalStateException: you have not supplyed the global app context info from SDKInitializer.initialize(Context) function. 05-11 15:19:14.901: E/unknown:React(18155): at com.baidu.platform.comapi.a.b(Unknown Source) 05-11 15:19:14.901: E/unknown:React(18155): at com.baidu.mapapi.BMapManager.init(Unknown Source) 05-11 15:19:14.901: E/unknown:React(18155): at com.baidu.mapapi.map.MapView.a(Unknown Source) 05-11 15:19:14.901: E/unknown:React(18155): at com.baidu.mapapi.map.MapView.(Unknown Source) 05-11 15:19:14.901: E/unknown:React(18155): at com.bee.baidumapview.BaiduMapViewManager.createViewInstance(BaiduMapViewManager.java:112) 05-11 15:19:14.901: E/unknown:React(18155): at com.bee.baidumapview.BaiduMapViewManager.createViewInstance(BaiduMapViewManager.java:19) 05-11 15:19:14.901: E/unknown:React(18155): at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:44) 05-11 15:19:14.901: E/unknown:React(18155): at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManag

后边显示: 05-11 15:19:14.974: E/AndroidRuntime(18155): FATAL EXCEPTION: mqt_native_modules

代码是你的样例程序,不知道什么问题; 你能验证一下吗?

blaine-liu commented 8 years ago

RN 0.25有几处API的变化,我今天修改了下代码,可以正常运行啦 1、修改index.js中的代码 import {PropTypes} from 'react' import { View,requireNativeComponent } from 'react-native';

2、替换BaiduMapShadowNode.java中的measure方法 @Override public void measure(CSSNode node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode, MeasureOutput measureOutput) { measureOutput.width = width; } 3、在BaiduMapViewManager.java中修改以下几处

Kingsearch commented 7 years ago

@Override public void measure(CSSNodeAPI node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode, MeasureOutput measureOutput) { measureOutput.width = width; }