Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bluebird88 opened this issue May 11, 2016 · 2 comments
Open

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

bluebird88 opened this issue May 11, 2016 · 2 comments

Comments

@bluebird88
Copy link

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
Copy link

blaine-liu commented May 20, 2016

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中修改以下几处

  • 删除旧的ReactPro导入声明,并且添加新版本的声明
    import com.facebook.react.uimanager.annotations.ReactProp;
  • 在createViewInstance方法中添加下面的代码
    SDKInitializer.initialize(mActivity.getApplicationContext());
    记得要在return 之前哦

@Kingsearch
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants