gpt4 book ai didi

javascript - React-native Android : Error calling AppRegistry. runApplication

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:54:37 26 4
gpt4 key购买 nike

我真的不知道这里发生了什么。我已经设置了一个基本应用程序并使用了找到的代码共享方法 here .这一切都非常基础,所以这是代码:

// index.android.js
// index.ios.js
import React, { AppRegistry } from 'react-native';
import CompetitionAgent from './app/index';

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

和组件:

//./app/index.js
import React, { Component } from 'react';
import {
StyleSheet,
Text,
TextInput,
View
} from 'react-native';

export default class CompetitionAgent extends Component {
constructor() {
super();
this.state = {nickname:''};
}
render() {
return (
<View style={styles.container}>
<View style={styles.information}>
<Text style={styles.welcome}>
Welcome to the Competition Agent Connect app!
</Text>
<Text style={styles.instructions}>
When you are near a Competition Agent, you can join the session.
</Text>
</View>
<View style={{padding:10}}>
<TextInput style={styles.inputStyle} />
</View>
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
information: {
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
inputStyle: {
flexDirection: 'row',
backgroundColor: '#3E3134',
color: '#FFFFFF',
}
});

我知道错误可能有很多。所以这个基本布局会产生同样的错误。

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

export default class CompetitionAgent extends Component {
constructor() {
super();
this.state = {nickname:''};
}
render() {
return (
<View style={styles.container}>
<Text style={styles.information}>
Welcome to the Competition Agent Connect app!
</Text>
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
information: {
alignItems: 'center',
backgroundColor: '#F5FCFF',
}
});

堆栈跟踪:

E/unknown:React: Exception in native call
java.lang.RuntimeException: Error calling AppRegistry.runApplication
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
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:158)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208)
at java.lang.Thread.run(Thread.java:818)
Caused by: com.facebook.jni.CppException: Could not get BatchedBridge, make sure your bundle is packaged correctly
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
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:158) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208) 
at java.lang.Thread.run(Thread.java:818) 

昨天运行得很好,重启 Android Studio 也没有帮助。

最佳答案

如果您从 Android Studio 运行您的应用程序,那么您必须从您的 React 项目文件夹中使用 react-native start 从命令行启动 react-native 打包程序。

您还必须使用 adb reverse tcp:8081 tcp:8081 设置 Android 端口转发。

你做到了吗?

关于javascript - React-native Android : Error calling AppRegistry. runApplication,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43776638/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com