React native: Android project not found. Maybe run react-native android first?

React Native-Android

React Native-Android Problem Overview


I had an issue in my React-Native project which was working fine earlier but suddenly it stopped working. Whenever I used the command:

react-native run-android

I was getting an error:

> Android project not found. Maybe run react-native android first?

I tried running:

react-native android

But it said:

> Unrecognized command 'android' Run react-native --help to see list of > all available commands

After trying:

D:\ProjectRoot\ReactNativeProjects\AwesomeProject>react-native eject

The error returned was:

> Scanning folders for symlinks in > D:\ProjectRoot\ReactNativeProjects\AwesomeProject\node_modules (48ms) > App name must be defined in the app.json config file to define the > project name. It must not contain any spaces or dashes.

This is the app.json file:

{
  "expo": {
    "name": "AwesomeProject",
    "description": "A very interesting project.",
    "slug": "AwesomeProject",
    "privacy": "public",
    "sdkVersion": "30.0.0",
    "platforms": ["ios", "android"],
	"ios": {
      "supportsTablet": true
    },
    "android": {
      "package": "com.project.first"
    },
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ]
  }
}

React Native-Android Solutions


Solution 1 - React Native-Android

I raised this question and answered myself as I thought it will help others who are facing similar issue. I struggled a lot to find out the real reason behind it as the error shown in terminal was not precise.

To resolve the issue please upgrade the react-native package.

  1. Go to the Project root.

  2. Upgrade the React native package in the Command Prompt by typing :

    react-native upgrade.

  3. Then Accept to update all the Files by typing y (Yes) in the Command Prompt.

Reference: https://github.com/facebook/react-native/issues/9312

Solution 2 - React Native-Android

Open your React Native Project Root Directory and locate android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json . delete signing-config.json this file try again

Or

1)Sometimes if we have older version of react native and some of newly installed packages dose not support older version. Then you have to update the react native project using react-native upgrade command.

  1. After done updating current project to new version this error should resolved.

Solution 3 - React Native-Android

I know it is an old question but any of those solutions did not work for me and maybe there are others like me. I solved my problem running this command before run-android

react-native eject

Solution 4 - React Native-Android

Make sure to start the project using command (non-expo):

react-native init <your-project-name>

If existing folder, then follow:

react-native eject


In the latest version of react-native this suggestion comes when you try to issue the command:

react-native eject

> Scanning folders for symlinks in > D:\ProjectRoot\ReactNativeProjects\AwesomeProject\node_modules (48ms) > App name must be defined in the app.json config file to define the > project name. It must not contain any spaces or dashes.

Now when you issue the following command:

D:\ProjectRoot\ReactNativeProjects\AwesomeProject>react-native upgrade

The following shows up:

> Scanning folders for symlinks in > D:\ProjectRoot\ReactNativeProjects\AwesomeProject\node_modules (56ms) > You should consider using the new upgrade tool based on Git. It makes > upgrades easier by resolving most conflicts automatically. To use it: > - Go back to the old version of React Native > - Run "npm install -g react-native-git-upgrade" > - Run "react-native-git-upgrade" See https://facebook.github.io/react-native/docs/upgrading.html > react-native version in "package.json" doesn't match the installed > version in "node_modules". Try running "npm install" to fix this. > Aborting.

In the Facebook react-native commands suggestions, there is a clear solution.

These commands check the current version and whether there is update needed or not.

One more solution:

react-native: Command run-android unrecognized. Maybe caused by npm install

Please also see:

Solution to "Expo : cannot find a module LogReporter"

Solution 5 - React Native-Android

Open Command Prompt as Administrator and goto the project folder, run android(npx react-native run-android)

Solution 6 - React Native-Android

I did like this... Worked !!

  1. In the CMD Project root run react-native upgrade.
  2. if you are still getting issues, make sure you have react-native in dependencies json in package.json, add it if not
  3. if you are still getting issues, get the version of react native in cmd using react-native -v and check if the value returned in cmd and package.json are same. update the package.json with the value returned in cmd

Here my problem solved.

Solution 7 - React Native-Android

Running Terminal as Administrator in Windows did the trick for me... Other solutions did not work.

Solution 8 - React Native-Android

I had to restyle my AndroidManifest.xml because I had a syntax error somewhere (I had an extra "/" somewhere). Now it's fixed. Be very careful with your syntax...

Solution 9 - React Native-Android

Remove the file: React Native Project Root Directory and locate android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json .

Solution 10 - React Native-Android

Open your React Native Project Root Directory and locate android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json

Delete the file and try again.

Solution 11 - React Native-Android

We had this issue because files from android folder gradlew and gradlew.bat (Gradle startup script for the UN*X, Windows respectively) somehow got into the global .gitignore file, and so were not presented on local environments.

Actually running react-native upgrade command restore those files, thus fixing the problem.

Solution 12 - React Native-Android

As a complement, in the case react-native command is not found, you should install react-native CLI:

npm install -g react-native-cli

Then you can follow the steps people said above.

More details: https://stackoverflow.com/questions/37189081/react-native-command-not-found

Solution 13 - React Native-Android

I faced this problem today, and none of the solutions worked for me, so I found another one.

Badly Formatted AndroidManifest.xml will cause this problem, perhaps you set the splash screen like me today, and didn't formatted AndroidManifest in the correct way

Solution 14 - React Native-Android

Delete signing-config.json next try again react-native run-android

signing-config.json file Path : android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json

Solution 15 - React Native-Android

If you started your project by following

npm install -g create-react-native-app
create-react-native-app MyReactNative
npm install -g react-native-cli
npm start

after this, you can face problem mention above in question So the solution is :

npm run eject

Solution 16 - React Native-Android

For me, "rm -rf android/app/build/" worked

Run your command with "--verbose". I got the error that it couldn't read a file (in android/app/build/generated/not_namespaced_r_class_sources/). I deleted this folder, and it worked

Solution 17 - React Native-Android

I think one more simple thing you could have checked, is if previously you ran the project as different role of a user, like in windows if you ran previously the react-native run-android with an administrator role.

Solution 18 - React Native-Android

Here, app.json does not have name, but it has expo related config. So just add name and display name fields in app.json.

app.json (first two lines) :

{
"name": "AwesomeProject",
"displayName": "Awesome Project",
"expo": {
    "name": "AwesomeProject",
    "description": "A very interesting project.",
    "slug": "AwesomeProject",
    "privacy": "public",
    "sdkVersion": "30.0.0",
    "platforms": ["ios", "android"],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "package": "com.project.first"
    },
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ]
  }
}

After this, just run :

$ react-native eject

info Generating the iOS folder.

info Generating the Android folder.

No need to do react-native upgrade.

Solution 19 - React Native-Android

I'm using Android Studio (non-expo) and this works for me

react-native init <your-project-name>

Solution 20 - React Native-Android

You have to run your cmd with admin priviliges. That solved the same issue for me. Didnt do "eject" or anything else.

Solution 21 - React Native-Android

In my case, I've forgotten to add Sudo. Fixed as follows,

sudo npx react-native run-android

Solution 22 - React Native-Android

Delete react native android build folder and then retry command npx react-native run-android

Solution 23 - React Native-Android

In my case i didn't had the right permissions for my project folder.

If this is your case just click with the right button on the folder > Properties > Security > Advanced and then change the ownership of the folder to your user, including the subfolders. That should do it

Solution 24 - React Native-Android

This error simply means you don't have 'android' and 'ios' folders in your root directory of the project. Their location is important.

SOLUTION:-

Open your project folder search for 'android' and iso 'folder', move these folders in your root folder of the project and then start the project with react-native run-android

enter image description here

Solution 25 - React Native-Android

So if there is anyone having this issue here what worked for me,

{
   "name": "ZedMusic",
   "displayName": "zedmusic",
   "expo": {}
}

the project name must be outside expo, then run npx react-native eject

Solution 26 - React Native-Android

My working solution is below, none of the above worked for me:

CD into your project folder and type expo start --android.

Or the long way:

  1. Open AVD manager in Android Studio and run a virtual device (you can close AS afterwards)
  2. CMD into your project folder and type 'expo start'
  3. Once Expo has started choose option 2 which is "Press a for Android emulator"

It will install expo on the virtual device and you can test from there

Solution 27 - React Native-Android

When I ran react-native eject, I got this error:

Both the iOS and Android folders already exist! Please delete `ios` and/or `android` before ejecting.
  • Delete the MyProject/android folder.

  • Run react-native eject This generated the android folder

  • Then run react-native run-android to build android

Solution 28 - React Native-Android

You should consider using the new upgrade tool based on Git. It makes upgrades easier by resolving most conflicts automatically. To use it:

Solution 29 - React Native-Android

If you have created your project with the expo command, like expo init projectname, then afterwards you have to eject your project:

expo eject

If you have created you project by react-native init projectName then you have to use

react-native eject

Solution 30 - React Native-Android

May be it's too late, I replaced the Android folder from a backup file. It worked for me.

Solution 31 - React Native-Android

I solved the issue by killing all instances of java.exe with: taskkill /f /im java.exe.

Solution 32 - React Native-Android

I had the same error in a project (created with React Native CLI):

enter image description here

turns out I had a syntax error in my android manifest file (android/app/src/main/AndroidManifest.xml).

Solution 33 - React Native-Android

On windows, my issue had been caused by using mklink to create a symlink to another folder of code.

I had: ProjectDir/common -> ../commonCode

Windows requires you to use mklink in admin mode, so I did. After that point, I could no longer run npx react-native run-android without getting this error, even running in an administrative cmd terminal.

Solution for me was to delete the mklink-created symlink and use ln -s ../commonCode common in the git bash terminal instead. This isn't ideal because of how windows handles symlinks, but gets me building again.

Otherwise, I had tried:

  • Deleting all of ./android/build and ./android/app/build (didn't help)
  • Running npx react-native run-android from cmd (didn't work)
  • Cleaning and reinstalling node_modules (no effect)
  • Double-checking AndroidManifest.xml for syntax errors (there were none)
  • npx react-native eject (eject isn't a command anymore)

Solution 34 - React Native-Android

In my case, I accidentally deleted AndroidManifest.xml in the android/app/src/main folder.

Solution 35 - React Native-Android

Open the project as an administrator.

react-native run-android

Attention: make sure you have reactive-native cli installed.

To install reactive-native cli on windows, run.

npm install -g react-native-cli

Solution 36 - React Native-Android

this error maybe happens after generating .apk for your project, or when you are in the development stage, then go to the android folder in the root of your react-native app and then check two following paths to delete signing-config.json file

1-

android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json

2-

android -> app -> build -> intermediates -> signing_config -> release -> out -> signing-config.json

Solution 37 - React Native-Android

For me it was a matter of stopping a firebase functions serve which was disallowing building or cleaning. So you may check if there is no serve you are running inside the project directory

Solution 38 - React Native-Android

You can simply resolve this issue by Go to node_modules folder then Go to glob folder and then Go to common.js in this file find (options.allowWindowsEscape = ture) now you have to change the true into false as this (options.allowWindowsEscape = false) Now hope your error will be resolved.

Solution 39 - React Native-Android

Make sure you did not have anything commented in AndroidManifest.xml.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionudaiView Question on Stackoverflow
Solution 1 - React Native-AndroidudaiView Answer on Stackoverflow
Solution 2 - React Native-AndroidSahil KalaigarView Answer on Stackoverflow
Solution 3 - React Native-AndroidJosé Abimael MartínezView Answer on Stackoverflow
Solution 4 - React Native-AndroidAbhinav SaxenaView Answer on Stackoverflow
Solution 5 - React Native-Androidkarthik manoView Answer on Stackoverflow
Solution 6 - React Native-Androidm9m9mView Answer on Stackoverflow
Solution 7 - React Native-AndroidAleksandarTView Answer on Stackoverflow
Solution 8 - React Native-AndroidBobo ChenView Answer on Stackoverflow
Solution 9 - React Native-AndroidNewPHPerView Answer on Stackoverflow
Solution 10 - React Native-AndroidGuilherme AndradeView Answer on Stackoverflow
Solution 11 - React Native-AndroidIlya ZatolokinView Answer on Stackoverflow
Solution 12 - React Native-AndroidFilipeView Answer on Stackoverflow
Solution 13 - React Native-AndroidBen Hur MartinsView Answer on Stackoverflow
Solution 14 - React Native-Androidأحمد رحمانيView Answer on Stackoverflow
Solution 15 - React Native-AndroidAbhiView Answer on Stackoverflow
Solution 16 - React Native-AndroidArnaud FouchetView Answer on Stackoverflow
Solution 17 - React Native-AndroidAjeet SinghView Answer on Stackoverflow
Solution 18 - React Native-Androidhp2017View Answer on Stackoverflow
Solution 19 - React Native-AndroidMichimcchickenView Answer on Stackoverflow
Solution 20 - React Native-AndroidhinoView Answer on Stackoverflow
Solution 21 - React Native-AndroidPraneeth PjView Answer on Stackoverflow
Solution 22 - React Native-AndroidThirashaView Answer on Stackoverflow
Solution 23 - React Native-AndroidYan JardimView Answer on Stackoverflow
Solution 24 - React Native-AndroidFaisal MushtaqView Answer on Stackoverflow
Solution 25 - React Native-AndroidMelvin ChipimoView Answer on Stackoverflow
Solution 26 - React Native-AndroidPaul GwamandaView Answer on Stackoverflow
Solution 27 - React Native-Androida_rahmanshahView Answer on Stackoverflow
Solution 28 - React Native-AndroidstainlessbabyView Answer on Stackoverflow
Solution 29 - React Native-AndroidDeepika kumariView Answer on Stackoverflow
Solution 30 - React Native-AndroidDinesh KumarView Answer on Stackoverflow
Solution 31 - React Native-AndroidKartik SonejiView Answer on Stackoverflow
Solution 32 - React Native-AndroidAmin DannakView Answer on Stackoverflow
Solution 33 - React Native-AndroidArtHareView Answer on Stackoverflow
Solution 34 - React Native-AndroidAbandonedEngineerView Answer on Stackoverflow
Solution 35 - React Native-AndroidFernando Lucas SouzaView Answer on Stackoverflow
Solution 36 - React Native-AndroidAbolfazlRView Answer on Stackoverflow
Solution 37 - React Native-AndroidNgonidzashe ManditsvangaView Answer on Stackoverflow
Solution 38 - React Native-AndroidTalal ZahidView Answer on Stackoverflow
Solution 39 - React Native-AndroidFaisal MushtaqView Answer on Stackoverflow