error: 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;
2
Answers
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 ofnpm install
. After runningyarn install
, the project loaded without those errors.I’m running a new project, and I meant to use
yarn
instead ofnpm
anyway, so this suffices for me. Sorry I can’t be of more valuable help. :You probably has installed some dependencies using a package manager and some with other.
Check if you have
package-lock.json
andyarn.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 justyarn
). This will make sure all dependencies listed atpackage.json
has been installed with the same package manager.After it just start your application as usual, and the error should be gone.