wix / react-native-navigation

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

Type mismatch: inferred type is StateWrapper #7916

Open HuZinnia opened 2 months ago

HuZinnia commented 2 months ago

What happened?

info A dev server is already running for this project on port 8081.
info Installing the app...

> Task :react-native-screens:compileDebugKotlin FAILED

> Task :react-native-navigation:compileReactNative71DebugKotlin FAILED
135 actionable tasks: 17 executed, 118 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 

e: file:///Users/HuZinnia/projectX/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt:47:58 Type mismatch: inferred type is StateWrapper? but StateWrapper was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactViewGroup.kt:7:59 Unresolved reference: fullBorderRadius
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/LayoutDirectionApplier.kt:11:45 Smart cast to 'ReactContext' is impossible, because 'instanceManager.currentReactContext' is a property that has open or custom getter
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/LayoutDirectionApplier.kt:12:45 Smart cast to 'ReactContext' is impossible, because 'instanceManager.currentReactContext' is a property that has open or custom getter
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:53:56 Type mismatch: inferred type is MotionEvent? but MotionEvent was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:53:70 Type mismatch: inferred type is EventDispatcher? but EventDispatcher was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:56:56 Type mismatch: inferred type is MotionEvent? but MotionEvent was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:56:70 Type mismatch: inferred type is EventDispatcher? but EventDispatcher was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:59:54 Type mismatch: inferred type is MotionEvent? but MotionEvent was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:59:68 Type mismatch: inferred type is EventDispatcher? but EventDispatcher was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:77:45 Type mismatch: inferred type is MotionEvent? but MotionEvent was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:77:52 Type mismatch: inferred type is EventDispatcher? but EventDispatcher was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:82:45 Type mismatch: inferred type is MotionEvent? but MotionEvent was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:82:52 Type mismatch: inferred type is EventDispatcher? but EventDispatcher was expected

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':react-native-screens:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':react-native-navigation:compileReactNative71DebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

BUILD FAILED in 2s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
e: file:///Users/HuZinnia/projectX/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt:47:58 Type mismatch: inferred type is StateWrapper? but StateWrapper was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactViewGroup.kt:7:59 Unresolved reference: fullBorderRadius
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/LayoutDirectionApplier.kt:11:45 Smart cast to 'ReactContext' is impossible, because 'instanceManager.currentReactContext' is a property that has open or custom getter
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/LayoutDirectionApplier.kt:12:45 Smart cast to 'ReactContext' is impossible, because 'instanceManager.currentReactContext' is a property that has open or custom getter
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:53:56 Type mismatch: inferred type is MotionEvent? but MotionEvent was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:53:70 Type mismatch: inferred type is EventDispatcher? but EventDispatcher was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:56:56 Type mismatch: inferred type is MotionEvent? but MotionEvent was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:56:70 Type mismatch: inferred type is EventDispatcher? but EventDispatcher was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:59:54 Type mismatch: inferred type is MotionEvent? but MotionEvent was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:59:68 Type mismatch: inferred type is EventDispatcher? but EventDispatcher was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:77:45 Type mismatch: inferred type is MotionEvent? but MotionEvent was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:77:52 Type mismatch: inferred type is EventDispatcher? but EventDispatcher was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:82:45 Type mismatch: inferred type is MotionEvent? but MotionEvent was expected
e: file:///Users/HuZinnia/projectX/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt:82:52 Type mismatch: inferred type is EventDispatcher? but EventDispatcher was expected FAILURE: Build completed with 2 failures. 1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':react-native-screens:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction > Compilation error. See log for more details * Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
============================================================================== 2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':react-native-navigation:compileReactNative71DebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction > Compilation error. See log for more details * Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

What was the expected behaviour?

No response

Was it tested on latest react-native-navigation?

Help us reproduce this issue!

I'm using the example code provided on the official website, as shown below:

function HomeScreen() {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Home Screen</Text>
    </View>
  );
}

const Stack = createNativeStackNavigator();

function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen name="Home" component={HomeScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

export default App;

In what environment did this happen?

React Native Navigation version: "^7.40.1" React Native version: "^0.75.3", Has Fabric (React Native's new rendering system) enabled: (yes/no)
Node version: v22.8.0 Device model: Android version:

ertugruldogan commented 2 months ago

It seems that the library used is not React-Native-Navigation.

function HomeScreen() {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>Home Screen</Text>
    </View>
  );
}
const Stack = createNativeStackNavigator();
function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen name="Home" component={HomeScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}
export default App;

because your code sample also belongs to the React-Navigation library that you are using :)

If it's React-Native-Navigation, look here. https://github.com/wix/react-native-navigation/issues/7905

Hao-yiwen commented 1 month ago

same question.how to resolve?

BogdanRad commented 1 month ago

@Hao-yiwen did you find the solution? I have same problem :(

WKampel commented 1 month ago

Same issue

prodevuk commented 1 month ago

Upgrade to the latest version of react native screens. This resolved my issue.

"react-native-screens": "^3.34.0"