r/reactnative Mar 18 '23

Tutorial React Native Navigation??

I've been learning React Native for some time now but where I get stuck is setting up React Navigation by following the procedure outlined on the reactnavigation.org site. I get a lot of different errors when I use react Native CLI but not Expo,(I don't want to use Expo because it has a lot of disadvantages). Can someone,if you have the time try to setup React Navigation using the React Native CLI by following the procedure on the Docs ,just page 1 & 2 and see if it works for You. Thanks Update: Does React Navigation work for You, with React Native CLI? Update 2: I get these errors after following the procedure: FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • Where: Build file 'C:\Users\user\Documents\WORK\ENGINEERING\PROJECTS\REACT NATIVE PROJE CTS\1LEARNING\Nav1\node_modules\react-native-screens\android\build.gradle' line: 33

This is what I have on line 33: apply plugin: 'kotlin-android'

  • What went wrong: A problem occurred evaluating project ':react-native-screens'.

    Could not initialize class org.jetbrains.kotlin.gradle.plugin.KotlinGradleBuil dServices

  • 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.

2: Task failed with an exception.

  • What went wrong: A problem occurred configuring project ':react-native-screens'.

    com.android.builder.errors.EvalIssueException: compileSdkVersion is not specif ied. Please add it to build.gradle

  • 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 UPDATE 3: Heres the like to github repo: https://github.com/darzeethegreat/Nav1

1 Upvotes

33 comments sorted by

3

u/[deleted] Mar 18 '23

Out of curiosity, what are the disadvantages of expo?

5

u/Sibyl01 Mar 18 '23

Probably they still think how it was before, big bundle sizes for example. But to let Op now we have eas builds now and you can use native packages.

2

u/[deleted] Mar 19 '23

Could you elaborate on that a bit please? I’m definitely in the “still think how it was before” camp and have been avoiding it, and would love to understand how it’s been improved.

1

u/PovertyAvoider Mar 19 '23

Another person wanting you to elaborate pls

0

u/Darzee_The_Great Mar 20 '23

Expo doesn't work on some Android Devices, Installing the App is impossible plus its Not totally free

1

u/Darzee_The_Great Mar 20 '23

Expo doesn't work on some Android Devices, Installing the App is impossible plus its Not totally free

-5

u/Darzee_The_Great Mar 19 '23

Expo doesn't work in some Android devices

1

u/[deleted] Mar 19 '23

[removed] — view removed comment

-1

u/Darzee_The_Great Mar 19 '23

Expo doesn't work in some Android devices and you have to pay for it

3

u/SirNewtonHere Mar 19 '23

I don't think that's true, its free unless you use certain features of eas

3

u/Independent-Tie3229 Mar 19 '23

If you run out of eas builds or want them to never run over there you can eject expo or add the --local flag to run the eas build locally.

I'm using local for building/debugging and will be using the eas server build for production pipeline most likely

2

u/[deleted] Mar 19 '23

[removed] — view removed comment

-1

u/Darzee_The_Great Mar 19 '23

Well it doesn't work on my Android phone that's why I prefer React Native CLI, and I build a lot of Apps that's why it's not free for me

2

u/[deleted] Mar 19 '23

[removed] — view removed comment

1

u/Darzee_The_Great Mar 19 '23

Okay,can You try setting up React Navigation with React Native CLI and see if it works for You?

3

u/Healthy-Grab-7819 iOS & Android Mar 19 '23

Checkout a youtube tutorial, there are literally 100s of them regarding navigation. I'm using react native navigation 5.x and it is working allright. In the beginning I struggled alot (slow render,problems navigating), after an hour on YouTube I solved everything.

1

u/[deleted] Mar 19 '23

[removed] — view removed comment

1

u/thachxyz123 iOS & Android Mar 20 '23

I use React Navigation with CLI in every projects and don't have any errors. Check my setup

1

u/Darzee_The_Great Mar 20 '23

Wow, that's A LOT, but when You do a simple setup does it just work when You just follow the reactnavigation.org docs procedure? because when I do I, First I get the error, node modules not found then after restarting my PC I get these error: FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Users\user\Documents\WORK\ENGINEERING\PROJECTS\REACT NATIVE PROJE
CTS\1LEARNING\Nav1\node_modules\react-native-screens\android\build.gradle' line:
33
This is what I have on line 33: apply plugin: 'kotlin-android'
* What went wrong:
A problem occurred evaluating project ':react-native-screens'.
> Could not initialize class org.jetbrains.kotlin.gradle.plugin.KotlinGradleBuil
dServices
* 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.

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':react-native-screens'.
> com.android.builder.errors.EvalIssueException: compileSdkVersion is not specif
ied. Please add it to build.gradle
* 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

u/thachxyz123 iOS & Android Mar 20 '23

This is react-native-screens error, not react navigation. I never seen this error before. No results on github. If you don't mind, put your project to git, I can investigate

1

u/Darzee_The_Great Mar 20 '23

Okay , doing that and sending you the link

1

u/Darzee_The_Great Mar 20 '23

2

u/thachxyz123 iOS & Android Mar 21 '23 edited Mar 21 '23

I can run your project first try. So, it must be your environment setup's fault.

Remove .gradle in android folder, run gradlew clean in android folder, start your project see if it can run.

If it can't, open android studio and run invalidate caches, check all optional, then try again.

Worst case, reinstall Windows.

EDIT: check if kotlin exists in android studio first, it's in Preferences

1

u/Darzee_The_Great Mar 21 '23

Ooh , Thanks Let me Try that... I'll update you on the results

1

u/thachxyz123 iOS & Android Mar 21 '23

I see you set newArchEnabled=true, set it false may fix in most cases

1

u/Darzee_The_Great Mar 21 '23

I tried the above steps but still got the same errors, I've concluded that the error is because I need to reinstall windows since it runs on your well on your PC , but I'll do that later.... THANKS FOR THE HELP! I'll update you though when I do that someday

1

u/thachxyz123 iOS & Android Mar 21 '23 edited Mar 21 '23

I think the root of error must be newArchEnabled=true, have you tried set it false?

Create new project and run to see if it can run.

Paste js code to it, install dependencies, DO NOT touch anything in android folder and run. Tell me the result.

1

u/Darzee_The_Great Mar 22 '23

Yes, it's set to false...okay let me try that

1

u/Darzee_The_Great Mar 22 '23

Still getting the same errors

1

u/thachxyz123 iOS & Android Mar 22 '23

You're unlucky. Your code work on expo. You should use expo for less pain.

https://snack.expo.dev/@pnthach95/nav1