wix / react-native-navigation

A complete native navigation solution for React Native
https://wix.github.io/react-native-navigation/
MIT License
13.01k stars 2.68k forks source link

react-native 0.73.2 project getting com.appName.mainActivity can not be cast to com.reactnativenavigation.NavigationActivity #7840

Open Martyneris opened 5 months ago

Martyneris commented 5 months ago

What happened?

I've installed the latest (7.37.2) version of react-native-navigation in my 0.73.2 react-native project, Android version builds but upon running the project I get the com.appName.mainActivity can not be cast to com.reactnativenavigation.NavigationActivity error. I want to emphasize that with the new 0.73.2 react-native version files I wasn't able to fully follow through with your installation. In react-native 0.73.2 MainActivity.java and MainApplication.java files are replaced with MainActivity.kt and MainApplication.kt respectively and they do not include any of the code that is described in react-native-navigation's installation guide, therefore I didn't know where or what to add.

What was the expected behaviour?

The project runs without any errors

Was it tested on latest react-native-navigation?

Help us reproduce this issue!

No response

In what environment did this happen?

React Native Navigation version: 7.37.2 React Native version: 0.73.2 Has Fabric (React Native's new rendering system) enabled: no Node version: 18.18.0 Device model: Emulator Android version: 14

asafkorem commented 4 months ago

@Martyneris can you please try the latest version? 7.38.0

aneena-thomas commented 4 months ago

Getting the same error 'com.lanch.MainActivity cannot be cast to com.reactnativenavigation.NavigationActivity' in 7.38.3

@asafkorem

ombogdanJoinToIt commented 4 months ago

same issue

aneena-thomas commented 4 months ago

Switching to .java fixed issues for me

ombogdanJoinToIt commented 4 months ago

@aneena-thomas do you have error in ios?

aneena-thomas commented 4 months ago

No errors. Keep the old MainActivity.java and MainApplication.java as it is.

ombogdanJoinToIt commented 4 months ago

@aneena-thomas I get errors on iOS

aneena-thomas commented 4 months ago

What are the errors you got? @ombogdanJoinToIt

ombogdanJoinToIt commented 4 months ago

I think this error does not belong to this thread @aneena-thomas Error: Component "myProjectID" does not have a componentId!

This error is located at: in WrappedComponent in RCTView in Unknown in RCTView in Unknown in AppContainer, js engine: hermes

rashidul0405 commented 3 weeks ago

This one is working for me:

package xx.xxx.xx

import com.facebook.react.ReactActivityDelegate
import com.reactnativenavigation.NavigationActivity
import com.facebook.react.ReactRootView
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled

class MainActivity : NavigationActivity() {
    class MainActivityDelegate(activity: NavigationActivity?, mainComponentName: String?) :
        ReactActivityDelegate(activity, mainComponentName) {

        override fun createRootView(): ReactRootView {
            val reactRootView = ReactRootView(context)
            // If you opted-in for the New Architecture, we enable the Fabric Renderer.
            reactRootView.setIsFabric(fabricEnabled)
            return reactRootView
        }
    }
}