Saahithyan Vigneswaran
Saahithyan Vigneswaran

Reputation: 7143

Clone and run react native projects from GitHub

I am trying to build and run react native application in my phone. I tried with Getting Started and it's working fine. I do the following to run

  1. cd AwesomeProject
  2. react-native start
  3. Open a new tab in terminal
  4. curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

  5. react-native run-android

and it runs in my android phone.

Now I am trying to run a project from GitHub, I did the following

  1. git clone https://github.com/h87kg/NavigatorDemo.git
  2. cd NavigatorDemo
  3. react-native start

I get Command 'start' unrecognized. Did you mean to run this inside a react-native project? error. What should I do to run this project ? Any help is appreciated. Thanks in advance.

Update

After installing dependencies npm install I am able to run the server. Now when I try to run react-native run-android I get the following error

JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Could not install the app on the device, see the error above.

Upvotes: 20

Views: 61002

Answers (5)

Rahul Dhiman
Rahul Dhiman

Reputation: 59

npm install react-native-fs --save --legacy-peer-deps

This will fix your issue

Upvotes: 0

Badmus Taofeeq
Badmus Taofeeq

Reputation: 769

The problem is that the gradlew file in the android folder isn't executable anymore because you cloned it from a git repo.

Basically, when you do react-native run-android, It does a lot of thing which includs running commands for you such as cd android && ./gradlew installDebug. right there, it tries to execute the gradlew, but can't, cause the file isn't executable. which is why you get that error.

just cd into the android folder, and do chmod +x gradlew.

Upvotes: 18

Surendra Pathak
Surendra Pathak

Reputation: 204

  1. Copy gradle folder inside android/ from my existing working project root
  2. Go to android directory and run this: ./gradlew installDebug
  3. Now copy your gradle folder back to the original location.

This is the solution that worked for me. Do not forget to close the node server during the process.

Upvotes: 1

Saahithyan Vigneswaran
Saahithyan Vigneswaran

Reputation: 7143

I have found the solution, this is how I got it working and sharing it with others who are facing the same problem

  1. Create a folder called assets inside android/app/src/main/
  2. Copied gradle folder inside android/ from my existing working project AwesomeProject
  3. (cd android && ./gradlew installDebug)
  4. curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
  5. react-native run-android

These are the exact steps I followed, hope it helps.

Upvotes: 1

Pir Shukarullah Shah
Pir Shukarullah Shah

Reputation: 4232

Did you install node modules? try npm install

  1. git clone https://github.com/h87kg/NavigatorDemo.git
  2. cd NavigatorDemo
  3. npm install
  4. react-native start

Upvotes: 22

Related Questions