2017-07-05 144 views
1

我試圖在我的設備上運行我的反應本機應用程序。 所以我正在運行react-native start 一切看起來不錯。 enter image description here應用程序項目尚未註冊

和運行react-native run-android,當我得到這個錯誤 enter image description here

否則,我得到這個錯誤在我的設備

enter image description here

+0

檢查你的index.andorid.js。檢查行AppRegistry.registerComponent .check是否已正確註冊該類。還要確保你在正確的項目文件夾 – Vicky

+0

我把class'proj extends Component'和應用程序註冊'AppRegistry.registerComponent('proj',()=> proj)'。 PS:我prject的名字是凸出 –

+0

請張貼代碼index.andorid.js – Vicky

回答

1

您需要導出類。使用下面的代碼

import React, { Component } from 'react' 
import { AppRegistry, Text, View } from 'react-native' 
export default class proj extends Component { 
render() { 
return ( 
<View style={styles.container}> <Text > Welcome to PutainDeBiere! </Text> </View>) 
} 
} 
AppRegistry.registerComponent('proj',() => proj) 
+0

:'我得到相同的錯誤:: –

+0

檢查你的index.ios.js下面的行應該是相同的,如果不使用在ios文件中的一個..第一個參數是項目的名稱..它應該是正確的。 AppRegistry.registerComponent('proj',()=> proj)..如果一切都失敗關閉所有內容並重新啓動 – Vicky

+0

我在index.ios.js中具有與index.android.js中相同的代碼。我得到了相同的錯誤 –

0

刪除/卸載首先安裝的APP,然後做一個乾淨的安裝它,看看它是否工作。

+0

我試過但現在:( –

+0

你是否將文件移動到另一個文件夾或其他東西?它可以導致問題,如果xcode文件和其他人不具有相同的名稱已在項目 – Brunaine

+0

嘗試在終端上:'lsof -i:8081'並使用終端上出現的幾個事情的PID,'kill -9 PID ',什麼都沒有嘗試再次運行APP – Brunaine

1

我的問題是我給起的名字不同的項目,該項目被註冊AppRegistry

AppRegistry.registerComponent('proj',() => proj) 

proj需求是一樣的gradle產出和配置文件的項目名稱的名字。