0

enter image description hereerror: cannot find symbol import com.swmansion.rnscreens.RNScreensPackage;

I am trying to run the app for Android platform but it's always failing. Can anyone please help me please check below one screenshot of error while compiling build for Android?

Steps to reproduce :- npm i react-native-screens npm run android build is compiling and throwing error as per below one

error: android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:33: error: cannot find symbol import com.swmansion.rnscreens.RNScreensPackage;

Kamlesh
  • 407
  • 1
  • 3
  • 17

3 Answers3

1

You probably has installed some dependencies using a package manager and some with other.

Check if you have package-lock.json and yarn.lock or another similar file from other package manager. Keep just the one from what you're using (yarn, npm, pnpm...) and remove all others.

Then run the command to install everything from package.json (ex. npm install or just yarn). This will make sure all dependencies listed at package.json has been installed with the same package manager.

Remember, if you kept yarn.lock so run yarn if you kept package-lock.json then run npm install.

After it just start your application as usual, and the error should be gone.

0

I ran into this issue as well. Unfortunately, I am not a Java or an Android developer, so I didn't know how to track down the reason that the Java packages were missing or why the were not being imported correctly.

I removed the four packages that appeared to be the source of the error, via npm remove:

  • @react-navigation/native
  • @react-navigation/native-stack
  • react-native-safe-area-context
  • react-native-screens

And then added them using yarn add instead of npm install. After running yarn install, the project loaded without those errors.

I'm running a new project, and I meant to use yarn instead of npm anyway, so this suffices for me. Sorry I can't be of more valuable help. :\

Jim McGaw
  • 768
  • 6
  • 13
-1

This React Native Screen version is not compatible with React Native 0.72 or higher.

To resolve this issue, follow these steps:

Open your project's build.gradle file at the project level. Add the following line inside the buildscript block, which defines the Kotlin version:

classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")

Make sure your buildscript block looks something like this:

buildscript {
    ext {
        // ... other configurations ...
        kotlinVersion = "1.8.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.0.0")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
        // ... other dependencies ...
    }
}

By adding this line, you specify the Kotlin version for your project.

Sync your Gradle project to apply these changes. This should resolve the compatibility issue with React Native 0.72+ for your React Native Screen version.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 02 '23 at 23:15