package.json
和build.grade
以使用react 0.18.0
,并且在启动时遇到了此错误。据我所知,AppRegistry
已正确导入。即使我注释掉代码,此错误仍会出现。这在iOS上没有问题。
我错在哪里?
编辑:尝试其他支持0.18.0的样板文件后,我仍然遇到相同的问题。
package.json
和build.grade
以使用react 0.18.0
,并且在启动时遇到了此错误。据我所知,AppRegistry
已正确导入。即使我注释掉代码,此错误仍会出现。这在iOS上没有问题。
我错在哪里?
编辑:尝试其他支持0.18.0的样板文件后,我仍然遇到相同的问题。
我刚刚升级到了 react-native 的版本 0.18.1
,但是使用预发行版 0.19.0-rc
时遇到了一些依赖问题。
回答你的问题,我所做的是:
cd android
sudo ./gradlew clean
(关于如何清除更多信息请看这里)然后返回工作目录并运行
react-native run-android
在升级之后也应该重新启动 npm。
希望这对你有用。
ANDROID_HOME
。我还添加了 local.properties
文件,并带有sdk.dir=
。有任何想法吗? - steezeburgersudo ./gradlew clean
的操作时,最好提到这是一个巨大的操作,它会重新下载和安装整个Gradle分发包。 - Szczepan Hołyszewski/Users/karim/Library/Android/sdk
- Karim Mortabit我在iOS上也遇到了同样的问题,原因是我的 index.ios.js 文件不正确(因为我复制粘贴了其中一个示例而没有查看其内容),它以模块导出声明结束。
exports.title = ...
exports.description = ...
module.exports = MyRootComponent;
与预期不同
AppRegistry.registerComponent('MyAppName', () => MyRootComponent);
我猜你在安卓上使用 index.android.js 也可能会遇到类似的问题。
这个问题的一个主要原因可能是您安装了插件但忘记链接它。
尝试这个:
react-native link
重新运行您的应用程序。
希望这可以帮助。请在评论中让我知道。谢谢。
react-native link
而不带包名将被弃用并移除。 - Harshad Madayeimport { AppRegistry } from "react-native";
import App from "./App";
import { name as appName } from "./app.json";
AppRegistry.registerComponent(appName, () => App);
请确保在您的index.js文件中存在此内容。
对于我来说,只需重新启动计算机即可解决问题。 (我的错误是“模块 appRegistry 不是已注册的可调用模块(调用 runapplication)JS 引擎:hermes”)
另一个排名较高的答案在这里缺失且可能有效,就是杀死所有 node 进程:
killall -9 node
[Module AppRegistry is not registered callable module (calling runApplication)]
node_modules
目录中执行以下命令:rm -rf node_modules
npm i
npx pod-install ios
对我来说,我的问题是在打包时放入了错误的入口文件。
我使用了App.js作为我的入口文件,因此App找不到AppRegistry。
正确:
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/
错误:
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/
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
一切正常,但是如果我使用 fastlane 发布应用程序,则会崩溃并显示以下错误:Module AppRegistry is not a registered callable module (calling runApplication)
在 build.gradle 中,我可能有一个错误的 entryFile!再次感谢! - Nobady希望这可以解决某人的问题。在升级我的React Native版本后,我遇到了这个错误。令人困惑的是,它只出现在Android端。
我的文件结构包括一个index.ios.js
和一个index.android.js
。两者都包含以下代码:
AppRegistry.registerComponent('App', () => App);
android/app/src/main/java/com/{projectName}/MainApplication.java
中,将index
更改为index.android
。@Override
protected String getJSMainModuleName() {
return "index.android"; // was "index"
}
然后在app/build/build.gradle
中,将entryFile
从index.js
更改为index.android.js
project.ext.react = [
entryFile: "index.android.js" // was index.js"
]
cd android
gradlew clean
重新启动您的应用程序
react-native run-android
检查一下是否直接在SafeAreaView中渲染某些内容。
确保你按照以下格式进行操作。
<SafeAreaView>
<View>
{children}
</View>
</SafeAreaView>
One of the sources for assign has an enumerable key on the prototype chain.
- Josh Ferrara