加载 Switch 组件报错,



  • 加载 Switch 组件报错, 另外一个项目加载却没有问题,代码都一样,求大神帮忙啊1_1457177367927_QQ图片20160305192915.png 0_1457177367927_QQ截图20160305192559.jpg



  • 03-05 19:37:06.001 6352-1762/com.example.paycenter_sample E/unknown:React: Exception in native call from JS
    java.lang.NullPointerException
    at android.text.StaticLayout.<init>(StaticLayout.java:48)
    at android.support.v7.widget.SwitchCompat.makeLayout(SwitchCompat.java:606)
    at android.support.v7.widget.SwitchCompat.onMeasure(SwitchCompat.java:526)
    at android.view.View.measure(View.java:15848)
    at com.facebook.react.views.switchview.ReactSwitchManager$ReactSwitchShadowNode.measure(ReactSwitchManager.java:56)
    at com.facebook.csslayout.CSSNode.measure(CSSNode.java:137)
    at com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:294)
    at com.facebook.csslayout.LayoutEngine.layoutNode(LayoutEngine.java:210)
    at com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:492)
    at com.facebook.csslayout.LayoutEngine.layoutNode(LayoutEngine.java:210)
    at com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:492)
    at com.facebook.csslayout.LayoutEngine.layoutNode(LayoutEngine.java:210)
    at com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:633)
    at com.facebook.csslayout.LayoutEngine.layoutNode(LayoutEngine.java:210)
    at com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:492)
    at com.facebook.csslayout.LayoutEngine.layoutNode(LayoutEngine.java:210)
    at com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:633)
    at com.facebook.csslayout.LayoutEngine.layoutNode(LayoutEngine.java:210)
    at com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:633)
    at com.facebook.csslayout.LayoutEngine.layoutNode(LayoutEngine.java:210)
    at com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:492)
    at com.facebook.csslayout.LayoutEngine.layoutNode(LayoutEngine.java:210)
    at com.facebook.csslayout.LayoutEngine.layoutNodeImpl(LayoutEngine.java:492)
    at com.facebook.csslayout.LayoutEngine.layoutNode(LayoutEngine.java:210)
    at com.facebook.csslayout.CSSNode.calculateLayout(CSSNode.java:146)
    at com.facebook.react.uimanager.UIImplementation.calculateRootLayout(UIImplementation.java:674)
    at com.facebook.react.uimanager.UIImplementation.dispatchViewUpdates(UIImplementation.java:445)
    at com.facebook.react.uimanager.UIManagerModule.onBatchComplete(UIManagerModule.java:423)
    at com.facebook.react.bridge.NativeModuleRegistry.onBatchComplete(NativeModuleRegistry.java:119)
    at com.facebook.react.bridge.CatalystInstanceImpl$NativeModulesReactCallback.onBatchComplete(CatalystInstanceImpl.java:442)
    at com.facebook.react.bridge.queue.NativeRunnableDeprecated.run(Native Method)
    at android.os.Handler.handleCallback(Handler.java:730)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
    at android.os.Looper.loop(Looper.java:137)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:184)
    at java.lang.Thread.run(Thread.java:841)
    03-05 19:37:06.001 6352-1762/com.example.paycenter_sample E/unknown:React: Exception in native call from JS
    java.lang.IllegalStateException: Previous layout was ignored! markLayoutSeen() never called
    at com.facebook.csslayout.CSSNode.dirty(CSSNode.java:167)
    at com.facebook.react.uimanager.ReactShadowNode.dirty(ReactShadowNode.java:111)
    at com.facebook.react.views.text.ReactTextShadowNode.markUpdated(ReactTextShadowNode.java:347)
    at com.facebook.react.views.text.ReactTextShadowNode.onBeforeLayout(ReactTextShadowNode.java:339)
    at com.facebook.react.uimanager.UIImplementation.notifyOnBeforeLayoutRecursive(UIImplementation.java:666)
    at com.facebook.react.uimanager.UIImplementation.notifyOnBeforeLayoutRecursive(UIImplementation.java:664)
    at com.facebook.react.uimanager.UIImplementation.notifyOnBeforeLayoutRecursive(UIImplementation.java:664)
    at com.facebook.react.uimanager.UIImplementation.notifyOnBeforeLayoutRecursive(UIImplementation.java:664)
    at com.facebook.react.uimanager.UIImplementation.notifyOnBeforeLayoutRecursive(UIImplementation.java:664)
    at com.facebook.react.uimanager.UIImplementation.notifyOnBeforeLayoutRecursive(UIImplementation.java:664)
    at com.facebook.react.uimanager.UIImplementation.notifyOnBeforeLayoutRecursive(UIImplementation.java:664)
    at com.facebook.react.uimanager.UIImplementation.notifyOnBeforeLayoutRecursive(UIImplementation.java:664)
    at com.facebook.react.uimanager.UIImplementation.notifyOnBeforeLayoutRecursive(UIImplementation.java:664)
    at com.facebook.react.uimanager.UIImplementation.dispatchViewUpdates(UIImplementation.java:443)
    at com.facebook.react.uimanager.UIManagerModule.onBatchComplete(UIManagerModule.java:423)
    at com.facebook.react.bridge.NativeModuleRegistry.onBatchComplete(NativeModuleRegistry.java:119)
    at com.facebook.react.bridge.CatalystInstanceImpl$NativeModulesReactCallback.onBatchComplete(CatalystInstanceImpl.java:442)
    at com.facebook.react.bridge.queue.NativeRunnableDeprecated.run(Native Method)
    at android.os.Handler.handleCallback(Handler.java:730)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
    at android.os.Looper.loop(Looper.java:137)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:184)
    at java.lang.Thread.run(Thread.java:841)


  • administrators

    Switch组件要求比较新的rn版本



  • @sunnylqm 我用的版本是
    compile 'com.facebook.react:react-native:0.20.1'



  • 经过一步一步的排插,我发现 Application 的主题 设置成 Theme.AppCompat.Light.NoActionBar才可以使用,我去,又默默地发现了一个坑
    ----2016年3月6日16:39:05


  • administrators

    @Pudding 不错,可以去官方issues汇报一下


登录后回复