不变冲突:"trackerApp"尚未注册



我挣扎了几天,出现了以下错误:

**Invariant Violation: "trackerApp" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.**

我检查了所有的东西,但都没用。

app.json中的代码

{
"name": "trackerApp",
"displayName": "trackerApp"
}

index.js中的代码

import {AppRegistry} from 'react-native';
import App from './App';
// import {name as appName} from './app.json';
import { name as appName } from "./app.json";
// import App from "./src/App.tsx";
// Register the service
AppRegistry.registerComponent(appName, () => App);

尝试清理缓存

cd android

然后

./gradlew clean

重新构建

如果不起作用,请删除node_modules文件夹,然后使用yarn installnpm install重新安装软件包。

如果仍然不工作,则检查这些文件,如果它们都具有";trackerApp";

1-root/package.json(通常在第2行(

{"name": "trackerApp"}

2-root/android/settings.gradle

rootProject.name = 'trackerApp'

3-root/android/app/src/debug/java/com/trackerApp/RectNativeFlipper.java(在注释下方的第一行代码上(

package com.trackerApp;

4-root/android/app/src/main/java/com/trackerApp/RectNativeFlipper.java

函数内部initializeFlipper检查是否为com.trackerApp.RreactNativeFlipper

Class<?> aClass = Class.forName("com.trackerApp.ReactNativeFlipper");

相关内容

  • 没有找到相关文章

最新更新