2016-10-10 358 views
4

最近,我们已经整合了反应本机到我们的应用程序,只是简单的文本视图。我们正在所有类型的设备上发生这种崩溃。JSApplicationIllegalArgumentException与React Native Android

Fatal Exception: com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'flex' in shadow node of type: RCTView 
     at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:109) 
     at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:148) 
     at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:52) 
     at com.facebook.react.uimanager.ReactShadowNode.updateProperties(ReactShadowNode.java:222) 
     at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:177) 
     at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:222) 
     at java.lang.reflect.Method.invoke(Method.java) 
     at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:318) 
     at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158) 
     at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java) 
     at android.os.Handler.handleCallback(Handler.java:739) 
     at android.os.Handler.dispatchMessage(Handler.java:95) 
     at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 
     at android.os.Looper.loop(Looper.java:234) 
     at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) 
     at java.lang.Thread.run(Thread.java:818) 
Caused by java.lang.IllegalArgumentException: method com.facebook.react.uimanager.LayoutShadowNode.setFlex argument 1 has type float, got java.lang.String 
     at java.lang.reflect.Method.invoke(Method.java) 
     at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:99) 
     at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:148) 
     at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:52) 
     at com.facebook.react.uimanager.ReactShadowNode.updateProperties(ReactShadowNode.java:222) 
     at com.facebook.react.uimanager.UIImplementation.createView(UIImplementation.java:177) 
     at com.facebook.react.uimanager.UIManagerModule.createView(UIManagerModule.java:222) 
     at java.lang.reflect.Method.invoke(Method.java) 
     at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:318) 
     at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158) 
     at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java) 
     at android.os.Handler.handleCallback(Handler.java:739) 
     at android.os.Handler.dispatchMessage(Handler.java:95) 
     at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 
     at android.os.Looper.loop(Looper.java:234) 
     at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196) 
     at java.lang.Thread.run(Thread.java:818) 

我们显示简单的文本与之反应原住民

'use strict'; 

import React from 'react'; 
import { 
    AppRegistry, 
    StyleSheet, 
    Text, 
    View 
} from 'react-native'; 

class HelloWorld extends React.Component { 
    render() { 
    return (
     <Text style={{color: 'white'}}>React Native is running</Text> 
    ) 
    } 
} 

AppRegistry.registerComponent('8fit',() => HelloWorld); 

我们使用阵营本地0.35.0-rc.0,但我们已经得到同样的崩溃也稳定版本0.33.1

你可以在这里找到完整的崩溃报告。 https://gist.github.com/sealskej/1e2398ef1cd9dda2d1b2630348fa612a

任何帮助导致修复问题将不胜感激!

+0

嘿,你能够重现上述代码的问题?我尝试了相同的代码,但没有得到崩溃。 – Jickson

+0

如果您使用flex关键字,请检入您的react-native代码库,并且该值是一个字符串。错误清楚地指定了一个字符串值,而不是浮动类型。 – Jickson

+0

你说'集成',所以它不是一个纯粹的React Native项目,对不对?代码看起来不错,它可能是一个设置错误。检查你的设置部分,你可能会发现一些东西。 – Swordsman

回答

1

我不明白为什么这不起作用,但可能的解决办法是将其包装在View中,并将值设置为flex。例如:

render() { 
    return (
     <View style={{flex: 1}}> 
     <Text style={{color: 'white'}}>React Native is running</Text> 
     </View> 
    ) 
    } 
+0

我会试试看。 – sealskej

+0

谢谢,它解决了这个问题。 – sealskej

0

的版本中使用可以比在APK正在使用的SDK版本不同的package.json文件反应。

这可以每次都给IllegalArgumentException。

+0

我使用'maven {url“$ rootDir/node_modules/react-native/android”}'和'compile“com.facebook.react:react-native:+”',这应该确保反应本地版本在' npm install',不是吗? – sealskej