2016-08-23 58 views
0

我試圖運行仿真器的應用程序,我看到這個錯誤 -陣營母語:港口相關的錯誤

enter image description here

我沒有在其他的終端和運行命令做出反應,天然起始packager已經啓動並在8081上運行。

任何想法可能是什麼問題?

感謝

回答

0

必須有語法錯誤,你可能會定義一個名爲「名稱」兩次屬性。嘗試檢查它。

+0

我是新來的反應原生的編程,而不是sur e哪個文件/哪裏檢查,因爲錯誤並不真正指向文件。 –

+0

如果你能向我展示一些代碼或你的index.android.js代碼,我會幫助你更好。 –

+0

再次感謝,包含下面的代碼。 –

0

這是index.android.js

/* @flow */ 
 

 
/** 
 
* Android index 
 
*/ 
 
'use strict'; 
 

 
var React = require('react-native'); 
 
var { 
 
    AppRegistry, 
 
} = React; 
 

 
/** 
 
* Sample React Native App 
 
* https://github.com/facebook/react-native 
 
*/ 
 

 
var MobileApp = require('./components/Index'); 
 

 
AppRegistry.registerComponent('MobileApp',() => MobileApp);

這是index.js看起來怎麼樣

/* @flow */ 
 

 
/** 
 
* Index with route mapper 
 
*/ 
 
'use strict'; 
 

 
var React = require('react-native'); 
 
var { 
 
    View, 
 
    AppRegistry, 
 
    Navigator, 
 
    AsyncStorage, 
 
} = React; 
 

 
var settings = require('../config/settings'), 
 
    apiErrors = require('../stores/ApiErrors.json'), 
 
    Util = require('../utils/Util'); 
 

 
//Components 
 
var Accounts = require('./Accounts'), 
 
    ActivityDashboard = require('./ActivityDashboard'), 
 
    Advice = require('./Advice'), 
 
    Dashboard = require('./Dashboard'), 
 
    History = require('./History'), 
 
    HealthQuiz = require('./HealthQuiz'), 
 
    HealthQuizCover = require('./HealthQuizCover'), 
 
    HealthQuizResult = require('./HealthQuizResult'), 
 
    HumanAPIConnect = require('./HumanAPIConnect'), 
 
    HumanConnectCordovaTest = require('./HumanConnectCordovaTest'), 
 
    LogIn = require('./LogIn'), 
 
    ManualAdd = require('./ManualAdd'), 
 
    MedicalInfo = require('./MedicalInfo'), 
 
    Overview = require('./Overview'), 
 
    Records = require('./Records'), 
 
    SignUp = require('./SignUp'), 
 
    WelcomeScenes = require('./WelcomeScenes'); 
 

 
if (settings.mode === 'dev') { 
 

 
} 
 

 
var RouteMapper = function(route, navigator) { 
 
    //Log route name 
 
    console.log('Route: ' + route.name); 
 

 
    if (route.name === 'Accounts') { 
 
    return (
 
     <Accounts navigator={navigator} /> 
 
    ); 
 
    } 
 
    else if (route.name === 'ActivityDashboard') { 
 
    return (
 
     <ActivityDashboard navigator={navigator} /> 
 
    ); 
 
    } else if (route.name === 'Advice') { 
 
    return (
 
     <Advice navigator={navigator} 
 
     component={route.component} 
 
     /> 
 
    ) 
 
    } else if (route.name === 'Dashboard') { 
 
    return (
 
     <Dashboard navigator={navigator} 
 
     component={route.component} 
 
     /> 
 
    ) 
 
    } else if (route.name === 'HealthQuiz') { 
 
    return (
 
     <HealthQuiz navigator={navigator} /> 
 
    ); 
 
    } else if (route.name === 'HealthQuizCover') { 
 
    return (
 
     <HealthQuizCover navigator={navigator} /> 
 
    ); 
 
    } else if (route.name === 'HealthQuizResult') { 
 
    return (
 
     <HealthQuizResult navigator={navigator} 
 
     result={route.result} 
 
     /> 
 
    ); 
 
    } else if (route.name === 'History') { 
 
    return (
 
     <History navigator={navigator} 
 
     component={route.component} 
 
     metric={route.metric} 
 
     /> 
 
    ) 
 
    } else if (route.name === 'HumanAPIConnect') { 
 
    return (
 
     <HumanAPIConnect navigator={navigator} /> 
 
    ); 
 
    } else if (route.name === 'HumanConnectCordovaTest') { 
 
    return (
 
     <HumanConnectCordovaTest navigator={navigator} /> 
 
    ); 
 
    } else if(route.name === 'LogIn') { 
 
    return (
 
     <LogIn navigator={navigator} /> 
 
    ); 
 
    } else if (route.name === 'LogOut') { 
 
    AsyncStorage.multiRemove(['email', 'username', 'auth', 'gender', 'age']); 
 
    console.log('Route: LogIn'); 
 

 
    return (
 
     <LogIn navigator={navigator} /> 
 
    ); 
 
    } else if(route.name === 'ManualAdd') { 
 
    return (
 
     <ManualAdd navigator={navigator} /> 
 
    ); 
 
    } else if (route.name === 'MedicalInfo') { 
 
    return (
 
     <MedicalInfo navigator={navigator} /> 
 
    ); 
 
    } else if (route.name === 'Overview') { 
 
    return (
 
     <Overview navigator={navigator} 
 
     mainSelection={true} 
 
     /> 
 
    ); 
 
    } else if (route.name === 'Records') { 
 
    return (
 
     <Records navigator={navigator} 
 
     component={route.component} 
 
     collection={route.collection} 
 
     /> 
 
    ); 
 
    } else if (route.name === 'SignUp') { 
 
    return (
 
     <SignUp navigator={navigator} /> 
 
    ); 
 
    } else if (route.name === 'WelcomeScenes') { 
 
    return (
 
     <WelcomeScenes navigator={navigator}/> 
 
    ); 
 
    } 
 
}; 
 

 
var Index = React.createClass({ 
 

 
    getInitialState: function() { 
 
    return {}; 
 
    }, 
 

 
    componentWillMount: function() { 
 
    AsyncStorage.multiGet(['username', 'auth', 'gender', 'age']).then((values) => { 
 
     var username = values[0][1], 
 
     auth = values[1][1], 
 
     gender = values[2][1], 
 
     age = values[3][1], 
 
     urlPattern = '/auth/confirm-auth/'; 
 

 
     if (!(username && auth && gender && age)) { 
 
     console.log('No username and/or auth were found'); 
 
     this.setState({initialRoute: 'LogIn'}); 
 
     } else { 
 
     this.setState({'username': username, 'auth': auth}); 
 
     Util.fetchAPIData(null, username, auth, urlPattern, null, this._handleAPIResponse, 
 
      this._onMissingConnection, this._handleFetchError, false); 
 
     } 
 
    }).done(); 
 
    }, 
 

 
    _onMissingConnection: function() { 
 
    this.setState({initialRoute: 'LogIn'}); 
 
    }, 
 

 
    _handleFetchError: function(error) { 
 
    console.log(error); 
 
    this.setState({initialRoute: 'LogIn'}); 
 
    }, 
 

 
    _handleAPIResponse: function(responseData) { 
 
    //Set initial route depending on whether or not credentials are valid 
 
    var initialRoute = (responseData.error == apiErrors.noError) ? 'Overview' : 'LogIn'; 
 
    this.setState({initialRoute: initialRoute}); 
 
    }, 
 

 
    render: function() { 
 

 
    //For debugging purposes 
 
    if (settings.mode === 'dev') { 
 
     return (
 
     <Navigator 
 
      initialRoute={{ 
 
      name: 'Accounts' 
 
      }} 
 
      renderScene={RouteMapper} 
 
     /> 
 
    ); 
 
    } 
 

 
    if (!('initialRoute' in this.state)) { 
 
     return <View/>; 
 
    } 
 

 
    return (
 
     <Navigator 
 
     initialRoute={{ 
 
      name: this.state.initialRoute 
 
     }} 
 
     renderScene={RouteMapper} 
 
     /> 
 
    ); 
 
    }, 
 

 
}); 
 

 

 
module.exports = Index;

+0

嘗試刪除if(settings.mode ==='dev')塊並運行它。名爲'name'的屬性的重定義可能發生在render()上。 –

+0

嗨弗蘭茲,感謝您的幫助,但沒有工作:(有什麼我可以嘗試嗎? –