React-Native : 모듈 AppRegistry는 등록 된 호출 가능 모듈이 아닙니다.
현재 Android 에뮬레이터 에서 ES6 react-native-webpack-server를 실행 하려고합니다 . 차이점은 업그레이드 package.json
하고 build.grade
react을 사용 0.18.0
하고 부팅 시이 오류가 발생 한다는 것 입니다. 내가 아는 AppRegistry
한 올바르게 가져옵니다. 코드를 주석 처리하더라도이 오류는 여전히 발생합니다. 이것은 문제없이 iOS에서 작동합니다.
내가 뭘 잘못하고 있죠?
편집 : 0.18.0을 지원하는 다른 상용구를 시도한 후에도 동일한 문제가 발생합니다.
나는 0.18.1
오늘 0.19.0-rc
출시 전 버전에서 피어 종속성 문제가 발생 하여 react-native로 업그레이드했습니다 .
질문으로 돌아가서 내가 한 일은
cd android
sudo ./gradlew clean
그런 다음 작업 디렉토리로 돌아가서 실행하십시오. react-native run-android
업그레이드 후에도 npm을 다시 시작해야합니다.
이것이 당신을 위해 작동하기를 바랍니다.
나는 iOS에서 같은 문제가 있었고 그 원인은 내 index.ios.js 가 잘못 되었다는 것입니다 (내용을 보지 않고 예제 중 하나를 복사하여 붙여 넣었 기 때문에) 모듈 내보내기 선언으로 끝났습니다.
exports.title = ...
exports.description = ...
module.exports = MyRootComponent;
예상 대신
AppRegistry.registerComponent('MyAppName', () => MyRootComponent);
내가 추측하는 index.android.js를 사용하여 Android에서 동일한 문제가 발생할 수 있습니다.
한 주 이 문제의 원인은 어디에있을 수 는 플러그인을 설치하고 연결하는 것을 잊지 것이다 .
이 시도:
react-native link
앱을 다시 실행하십시오.
이것이 도움이되기를 바랍니다. 댓글로 알려주세요 . 감사.
이 문제를 해결했습니다.
import { AppRegistry } from "react-native";
import App from "./App";
import { name as appName } from "./app.json";
AppRegistry.registerComponent(appName, () => App);
내 index.js에
이것이 index.js 에 있는지 확인하십시오.
Hopefully this can save someone a headache. I got this error after upgrading my react-native version. Confusingly it only appeared on the android side of things.
My file structure includes an index.ios.js
and an index.android.js
. Both contain the code:
AppRegistry.registerComponent('App', () => App);
What I had to do was, in android/app/src/main/java/com/{projectName}/MainApplication.java
, change index
to index.android
:
@Override
protected String getJSMainModuleName() {
return "index.android"; // was "index"
}
Then in app/build/build.gradle
, change the entryFile
from index.js
to index.android.js
project.ext.react = [
entryFile: "index.android.js" // was index.js"
]
I don't know why, but when I move AppRegistry.registerComponent from the index.js file that is included in index.android.js to reside inside index.android.js directly, it seems to work.
For me my issue was putting the wrong entry-file when bundling.
I was using App.js as my entry-file, hence the App couldn't find AppRegistry
Correct:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
Incorrect:
react-native bundle --platform android --dev false --entry-file App.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
If you are using some of the examples they might not work
Here is my version for scroll view
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
import React, {
AppRegistry,
Component,
StyleSheet,
Text,
View,
ScrollView,
TouchableOpacity,
Image
} from 'react-native';
class AwesomeProject extends Component {
render() {
return (
<View>
<ScrollView
ref={(scrollView) => { _scrollView = scrollView; }}
automaticallyAdjustContentInsets={false}
onScroll={() => { console.log('onScroll!'); }}
scrollEventThrottle={200}
style={styles.scrollView}>
{THUMBS.map(createThumbRow)}
</ScrollView>
<TouchableOpacity
style={styles.button}
onPress={() => { _scrollView.scrollTo({y: 0}); }}>
<Text>Scroll to top</Text>
</TouchableOpacity>
</View>
);
}
}
var Thumb = React.createClass({
shouldComponentUpdate: function(nextProps, nextState) {
return false;
},
render: function() {
return (
<View style={styles.button}>
<Image style={styles.img} source={{uri:this.props.uri}} />
</View>
);
}
});
var THUMBS = [
'http://loremflickr.com/320/240?random='+Math.round(Math.random()*10000) + 1,
'http://loremflickr.com/320/240?random='+Math.round(Math.random()*10000) + 1,
'http://loremflickr.com/320/240?random='+Math.round(Math.random()*10000) + 1
];
THUMBS = THUMBS.concat(THUMBS); // double length of THUMBS
var createThumbRow = (uri, i) => <Thumb key={i} uri={uri} />;
var styles = StyleSheet.create({
scrollView: {
backgroundColor: '#6A85B1',
height: 600,
},
horizontalScrollView: {
height: 120,
},
containerPage: {
height: 50,
width: 50,
backgroundColor: '#527FE4',
padding: 5,
},
text: {
fontSize: 20,
color: '#888888',
left: 80,
top: 20,
height: 40,
},
button: {
margin: 7,
padding: 5,
alignItems: 'center',
backgroundColor: '#eaeaea',
borderRadius: 3,
},
buttonContents: {
flexDirection: 'row',
width: 64,
height: 64,
},
img: {
width: 321,
height: 200,
}
});
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);
I uninstalled it on Genymotion. Then run react-native run-android
to build the app. And it worked. Do try this first before running sudo ./gradlew clean
, it will save you a lot of time.
For just restarting the computer fixed it. (My error was "module appRegistry is not a registered callable module (calling runapplication) js engine: hermes")
Another top answer that is missing here and might have worked was just to kill node processes:
killall -9 node
[ Module AppRegistry is not registered callable module (calling runApplication) ]
In my case, my index.js
just points to another js instead of my Launcher js mistakenly, which does not contain AppRegistry.registerComponent()
.
So, make sure the file yourindex.js
point to register the class.
My issue was fixed by increasing my inotify max_user_watches:
sudo sysctl fs.inotify.max_user_watches=1280000
For me it was a issue with react-native dependency on next version of react package, while in my package.json the old one was specified. Upgrading my react version solved this problem.
For me just i linked with react native as this way : react-native link
restart packager worked for me. just kill react native packager and run it again.
if you are facing this error in windows with android
open your root directory app folder and move into android folder .
cd android
gradlew clean
start your app again react-native run-android
bhooom it works
npm start -- --reset-cache
Probably port is already in use. I face similar issue when i first run react-native run-android and then npm start. I solve it like this: First, get the id of the process running in port 8081: sudo lsof -i :8081
'IT story' 카테고리의 다른 글
Maven에서 "401 Unauthorized"오류가 발생하는 이유는 무엇입니까? (0) | 2020.08.19 |
---|---|
R의 인쇄 출력에서 소수 자릿수 제어 (0) | 2020.08.19 |
사용 가능한 무료 Xml Diff / Merge 도구가 있습니까? (0) | 2020.08.19 |
ConcurrentBag <>에서 단일 특정 개체를 제거하는 방법은 무엇입니까? (0) | 2020.08.19 |
사용하지 않는 참조 제거 (! = "using") (0) | 2020.08.19 |