Paul
Paul

Reputation: 11

Cannot get React-Native-Navigation installed for the life of me

I am working on implementing wix navigation to my React Native project. So far I have:

I have solved most of the errors that I was getting but I am left with this one:

> [email protected] android 
> react-native run-android

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1237 file(s) to forward-jetify. Using 12 workers...
info Starting JS server...
info Installing the app...
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Paul\Documents\Projects\3sidedcube\pokedecks\node_modules\react-native-navigation\lib\android\app\build.gradle' line: 177

* What went wrong:
A problem occurred evaluating project ':react-native-navigation'.
> Cannot run program "C:\Users\Paul\AppData\Local\Android\Sdk/cmdline-tools/latest/bin/sdkmanager": CreateProcess error=2, The system cannot find the file specified  

* 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 14s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Paul\Documents\Projects\3sidedcube\pokedecks\node_modules\react-native-navigation\lib\android\app\build.gradle' line: 177

* What went wrong:
A problem occurred evaluating project ':react-native-navigation'.
> Cannot run program "C:\Users\Paul\AppData\Local\Android\Sdk/cmdline-tools/latest/bin/sdkmanager": CreateProcess error=2, The system cannot find the file specified  

* 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 14s

    at makeError (C:\Users\Paul\Documents\Projects\3sidedcube\pokedecks\node_modules\execa\index.js:174:9)
    at C:\Users\Paul\Documents\Projects\3sidedcube\pokedecks\node_modules\execa\index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (C:\Users\Paul\Documents\Projects\3sidedcube\pokedecks\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
    at async Command.handleAction (C:\Users\Paul\Documents\Projects\3sidedcube\pokedecks\node_modules\@react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.

It seems to be a problem with the path to the SDK?

if (!buildToolsDir.exists()) {
    def command = sdkDir.absolutePath + "/cmdline-tools/latest/bin/sdkmanager build-tools;" + buildToolsVersion
    command.execute().waitForProcessOutput(System.out, System.err)
}

This is line 177, I can see it relates to the SDK path and I dont know where the build-tools come from as in the path on my system, its just sdkmanager.bat.

So I changed this to:

if (!buildToolsDir.exists()) {
    def command = sdkDir.absolutePath + "/cmdline-tools/latest/bin/sdkmanager.bat;
    command.execute().waitForProcessOutput(System.out, System.err)
}

It now compiles to the executing phase and then crashes giving me this;

* What went wrong:
Could not determine the dependencies of task ':react-native-navigation:compileReactNative63DebugAidl'.

> Installed Build Tools revision 33.0.0 is corrupted. Remove and install again using the SDK Manager.

I am at a total loss. It seems this package is just prone to errors and bugs, from my researching companies hate it, but I must use it.

Upvotes: 0

Views: 502

Answers (1)

abdemirza
abdemirza

Reputation: 659

Step 1:

yarn add react-native-navigation

Step 2:

pod install --project-directory=ios  

Step 3: Edit the index.js file

import { Navigation } from "react-native-navigation";
import App from "./App";

Navigation.registerComponent('com.myApp.WelcomeScreen', () => App);

Navigation.events().registerAppLaunchedListener(() => {
   Navigation.setRoot({
     root: {
      stack: {
         children: [
           {
             component: {
               name: 'com.myApp.WelcomeScreen'
             }
           }
         ]
       }
    }
  });
});

Step 4: Kill the app, close the react-native terminal and build the project again

Upvotes: 0

Related Questions