React本机运行保持空闲状态

时间:2018-08-25 14:31:58

标签: reactjs android-studio react-native android-sdk-tools

这是我第一次在 import React, { Component } from 'react'; import { AppRegistry } from 'react-native' import { ViroARSceneNavigator } from 'react-viro'; var apiKey = "XXXXXX-XXXX"; var arScene = { 'FirstScene': require('./FirstScene') } export default class ARConfig extends Component { render(){ return( <ViroARSceneNavigator initialScene={{ scene: arScene['FirstScene'], }} apiKey={apiKey} /> ) } } AppRegistry.registerComponent('XXXX', () => ARConfig); 上设置本机反应。我已经完成设置,并且试图使用 import React, { Component } from 'react'; import { AppRegistry, StyleSheet } from 'react-native'; import { ViroARScene, ViroText, ViroConstants } from 'react-viro'; export default class FirstScene extends Component{ constructor(){ super(); this.state={ hasInitialized : false, text: "Initializing AR..." } } return(){ render( <ViroARScene onTrackingUpdated={this.onTrackingUpdated()}> <ViroText text={this.state.text} scale={[.5, .5, .5]} position={[0, 0, -1]} style={styles.helloWorldTextStyle} /> </ViroARScene> ) } onTrackingUpdated(state, reason){ if (!this.state.hasInitialized && state == ViroConstants.TRACKING_NORMAL){ this.setState({ hasInitialized: true, text: 'hello Rocky!!!' }) } } } var styles = StyleSheet.create({ helloWorldTextStyle: { fontFamily: 'Arial', fontSize: 30, color: '#ffffff', textAlignVertical: 'center', textAlign: 'center', }, }); AppRegistry.registerComponent('XXXX', () => FirstScene); 命令在设备上运行该应用程序。 这是我在终端中得到的输出,

TypeError: Cannot set property 'viroAppProps' of undefined

This error is located at:
    in ViroARSceneNavigator (at ARConfig.js:11)
    in ARConfig (at navigationStore.js:525)
    in Wrapped (at SceneView.js:17)
    in SceneView (at CardStack.js:466)
    in RCTView (at View.js:71)
    in View (at createAnimatedComponent.js:147)
    in AnimatedComponent (at Card.js:12)
    in Card (at PointerEventsContainer.js:39)
    in Container (at CardStack.js:498)
    in RCTView (at View.js:71)
    in View (at CardStack.js:414)
    in RCTView (at View.js:71)
    in View (at CardStack.js:413)
    in CardStack (at CardStackTransitioner.js:67)
    in RCTView (at View.js:71)
    in View (at Transitioner.js:142)
    in Transitioner (at CardStackTransitioner.js:19)
    in CardStackTransitioner (at StackNavigator.js:41)
    in Unknown (at createNavigator.js:13)
    in Navigator (at createNavigationContainer.js:226)
    in NavigationContainer (at SceneView.js:17)
    in SceneView (at CardStack.js:455)
    in RCTView (at View.js:71)
    in View (at CardStack.js:454)
    in RCTView (at View.js:71)

它永远保持在此IDLE位置。解决了什么问题?

2 个答案:

答案 0 :(得分:3)

解决方案是安装Android SDK rev. 26.0.3。您可以从SDK Manager的Android Studio的File > Settings菜单中进行安装。希望这会有所帮助。

答案 1 :(得分:0)

我今天遇到了同样的错误。解决方案是创建一个名为local.properties的文件,并在此行中写入:

sdk.dir=[the position of android sdk]

示例:

sdk.dir=N\:\\Users\\andy\\AppData\\Local\\Android\\Sdk

您可以通过android studio获得SDK android:Android Studio - How to Change Android SDK Path

希望这会对您和刚开始学习的其他人有所帮助。