Ellie
Ellie

Reputation: 11

react-native-paper "main" has not been registered error at startup

I cannot run my app on Android when using react-native-paper, I come to this conclusion because my app runs fine when I remove the import for react-native-paper in app.js

The error:

(NOBRIDGE) LOG Bridgeless mode is enabled (NOBRIDGE) ERROR Error: URL.protocol is not implemented (NOBRIDGE) ERROR Invariant Violation: "main" 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.

My package.json:

{
  "name": "my-app",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@expo/metro-runtime": "~4.0.1",
    "@react-navigation/native": "^7.0.14",
    "@react-navigation/stack": "^7.1.1",
    "expo": "~52.0.26",
    "expo-status-bar": "~2.0.1",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "react-native": "0.76.6",
    "react-native-fast-image": "^8.6.3",
    "react-native-gesture-handler": "^2.22.0",
    "react-native-paper": "^5.13.0",
    "react-native-safe-area-context": "4.12.0",
    "react-native-screens": "^4.4.0",
    "react-native-url-polyfill": "^2.0.0",
    "react-native-vector-icons": "^10.2.0",
    "react-native-web": "~0.19.13"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true
}

My index.js:

import { Provider as PaperProvider } from 'react-native-paper';
import App from './App';
import 'react-native-gesture-handler';
import { registerRootComponent } from 'expo';

export default function Main() {
  return (
    <PaperProvider>
      <App />
    </PaperProvider>
  );
}

registerRootComponent(Main);

Any help is appreciated, I've considered moving to other library if possible but I still want to know what cause this issue?

Upvotes: 0

Views: 112

Answers (0)

Related Questions