Facing issue " Failed to install the app. Make sure you have the Android development environment " in react native

React NativeReact Native-AndroidAndroid Sdk-Tools

React Native Problem Overview


Would you please help me, I am stuck to create a new project in react-native Like below screenshot. I have able to run old projects. but I am not able to run a new project

I have followed these steps:

  1. react-native init projectName
  2. cd projectName
  3. react-native run-projectName

But I get the error below:

error Failed to install the app. Make sure you have the Android development environment set up:

Screenshot

React Native Solutions


Solution 1 - React Native

I was receiving this error message when running react-native run-android.

When I ran cd android && ./gradlew clean I was getting permission errors also.

I ran chmod +x gradlew and it started working

Solution 2 - React Native

To make sure your environment is setup properly for android, go to the root of your react-native project. Open the android project(folder) in the Android Studio IDE.

All errors with your environment will show up, and that will automatically start the Gradle Daemon to sync and configure the build for you. Once it finished, close the Android Studio and come back to command-line and run: react-native run-android

This works fine.

Solution 3 - React Native

This command chmod +x gradlew work for me in mac.

Solution 4 - React Native

Run the following command

cd .\android\ 
./gradlew clean

Then in the root of your project:

npx react-native start --reset-cache

NOTE

Make sure that the app does not exist on your phone, if so, first try to remove it then run your project again

Solution 5 - React Native

Just do $:cd android and then $: gradlew clean worked for me on Windows

Solution 6 - React Native

Hi I fixed this issue by wipe data of the emulator. Go to android studio -> then open AVD Manager -> Click the triangle icon of the emulator. -> then click Wipe data.

after that run react-native run-android . This fixed my issue. enter image description here

Solution 7 - React Native

Open ~/.bash_profile and add:

 export ANDROID_HOME=~/Library/Android/sdk/

 export PATH=$PATH:~/android-sdks/platform-tools/

 export PATH=$PATH:~/android-sdks/tools/

source ~/.bash_profile

Solution 8 - React Native

Make sure the Android SDK is connected correctly to the terminal shell as described in the docs. This solved the problem on my machine after generating a bare workflow expo project.

https://reactnative.dev/docs/environment-setup

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

Solution 9 - React Native

Edit:

According to the updated questions, with screenshots comment below, seems like your problem is related to this other post from years ago.

The solution I could provide for you is to find your gradle.zip* file, delete it, and re-run the command. That way, the command would try downloading the gradle again. And this time, please make sure your connection is stable during the command run process, as the command will re-download the gradle zip again.

For reasons of the solution I provided, according to the link, it is caused by your connection is unstable and the gradle zip downloaded during the process is corrupted.

Previous Answer:

Do you have Android Studio installed on your computer?

Have you tried running the command again after you started an Android emulator device from Android Studio?

The command you mentioned AFAIK, does not try to run any emulator for you, and you need to run an emulator yourself to test your app.

Also you need to have Android SDK installed to run a react-native android-app. It does not comes with react-native, but it does comes with Android Studio.

So, maybe you should start there!

Solution 10 - React Native

You can do this :

Open Android Studio > Configure > AVD Manager > Stop virtual device

Finally :

npx react-native run-android 

This works for me.

Solution 11 - React Native

This command worked for me -

cd android
chmod +x gradlew

Solution 12 - React Native

This error usually happens when you're running an app that you've never run before on your computer. A simple way of solving this issue is that:

  1. Open and run your app on Android Studio
  2. Let it build everything in the Gradle.
  3. Once it's done, close Android Studio
  4. Open your App back on Visual Studio Code and it will work just fine.

Solution 13 - React Native

In my case, I was getting this error only when I try to run it on my physical device. Activating Install via USB from Developer Options fixed the problem.

Solution 14 - React Native

I too stumbled into this problem today. It happens when you take project form other users. Hence the ndk and sdk path are of the other user. So make sure the ndk and sdk path are correctly mentioned inside your local.properties file.

Solution 15 - React Native

  1. ..\..\android\.gradle open your project's gradle directory
  2. There is gradle version directory. Delete it and download the new version from https://services.gradle.org/distributions/
  3. Then paste the new version to your directory.

Open vscode and go android → gradle/wrapper → gradle-wrapper.properties and after the new gradle version has been downloaded, we have to change

distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip

to

distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip

Solution 16 - React Native

THIS WORKED IN UBUNTU

use the below code to open the editor

sudo gedit ~/.bashrc

And then paste the following lines in the last (Make sure to specify path names according to you system paths)

export BASE_DIR="/home/sid"
export ANDROID_SDK=$BASE_DIR/Sdk
export ANDROID_PATH=$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools
export ANDROID_HOME=$BASE_DIR/Sdk
export FLUTTER=$BASE_DIR/developement/flutter/bin
export PATH=$PATH:$BASE_DIR:$ANDROID_PATH:$ANDROID_HOME:$FLUTTER
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/emulator


JAVA_HOME="/home/sid/android-studio/jre"
PATH="$PATH:$HOME/bin:$JAVA_HOME/bin"
export JAVA_HOME
export JRE_HOME
export PATH

And finally run the following code in terminal to make changes

source ~/.bashrc

Solution 17 - React Native

For me what worked was setting up adb reverse, then clearing the development server cache.

Step 1:

Follow this link and set up adb reverse.

Step 2: Run this to clear development server cache:

npx react-native start --reset-cache

Finally: Run this to bundle android file and install debug apk on your device:

npx react-native run-android

Solution 18 - React Native

For me the problem was that the res folder under android/app/src/res was deleted so i can make an apk. Then the project was pushed on git with the deleted file. I solved the problem by adding the res file again to the project.

Solution 19 - React Native

npx --quiet react-native config or npx.cmd --quiet react-native config

This works for me.

Solution 20 - React Native

If you have expo installed on your project then run expo start --android instead of npm run android. This is how i got my app to run.

Solution 21 - React Native

In windows solve it with the attrib command. The gradle directory may require write permissions.

proyect> cd android (enter)
proyect/android> attrib -r gradle (enter)

Solution 22 - React Native

I also had below error

Task :react-native-charts-wrapper:mergeDebugJniLibFolders FAILED

and fixed it by adding below change in android/build.gradle:

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.google.android.gms'
                && details.requested.name.contains('play-services-gcm')) {
                details.useVersion '16.0.0'
            }
        }
    }
}

Solution 23 - React Native

This worked for me on Windows 10

cd android && chmod +x gradlew

If you are getting an error saying **'chmod' is not recognized as an internal or external command** then you need to install Git

Download and install git.
Then
  • Got to the C drive In Program Files folder, you will find the folder named Git, find usr then bin.

  • In my case, the location for bin folder was:

    • C:\Program Files\Git\usr\bin
  • Add this location C:\Program Files\Git\usr\bin to path variables, in system environment variables.

  • Restart cmd.

Finally Try again
cd android && chmod +x gradlew

Good Luck

Solution 24 - React Native

A workaround for this is basically just run the app on your physical device using wi-fi connection.

1 - Open your cmd;

2 - > adb tcpip 5555;

3 - With your device IP, run the following command: adb connect deviceIp;

(In case you don't know how to find your device's ip´: https://help.simpletelly.com/article/329-how-to-find-your-android-device-ip-address )

Solution 25 - React Native

Make sure your dependencies are updated to support your react-native version (for me it was react-native-navigation when I updated to RN65).

Solution 26 - React Native

In my case I had ANDROID_HOME environment variable set correctly ... but the error has more details saying:

Unable to make field private final java.lang.String java.io.File.path accessible

Which means I installed the wrong version of Java JDK which is JDK 17 which is not supported by the time of this answer...

Downgrading Java JDK to Java JDK 11 resolved the issue

Solution 27 - React Native

In January 2022, I had this same issue. I am using a Windows 11 machine running AMD Ryzen 3. All the steps given above failed me. The only solution that worked for me was turning off my Avast anti-virus and running npx react-native run-android again.

The antivirus has a ransomware shield that was preventing certain actions, so when I checked the error logs and found areas where Access Denied was the issue, I figured it could be my antivirus.

Another way I could have solved this would be to move the project folder to a different directory other than my Desktop (which is a protected directory) or change the protection settings from my Avast ransomware settings so that Desktop would no longer be a protected directory.

Solution 28 - React Native

Make sure you have Java JDK installed - for Ubuntu 20.04 - sudo apt install openjdk-11-jdk fixed it for me

Solution 29 - React Native

In my case, I have already installed an app with the same identifier, i.e. com.appname. So first, I remove it from the device.

Don't forget to do a ./gradlew clean

Solution 30 - React Native

In my case, it occurred after I added to android/app/src/main/res/raw a sound with the name in camelCase. When I changed it to cebab_case, it all worked fine again.

Solution 31 - React Native

I was facing same issue. I used npm to install the Expo CLI command line utility

npm install -g expo-cli

In your React Native project directory run

npm start 

Or you can also use:

expo start

This works for me

Solution 32 - React Native

You can use the alternative way to run react native her both way to run app more details app I have solved this
installing expo - npm package,
npm add expo
and starting the project
expo start

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
QuestionPraful ArgiddiView Question on Stackoverflow
Solution 1 - React NativeDylan wView Answer on Stackoverflow
Solution 2 - React NativeA. NadjarView Answer on Stackoverflow
Solution 3 - React NativeMenon HasanView Answer on Stackoverflow
Solution 4 - React NativeAbolfazlRView Answer on Stackoverflow
Solution 5 - React NativeVikram KodagView Answer on Stackoverflow
Solution 6 - React NativeNishaView Answer on Stackoverflow
Solution 7 - React NativeKeshav GangwalView Answer on Stackoverflow
Solution 8 - React NativeNur Iman IzamView Answer on Stackoverflow
Solution 9 - React NativeJaKK's TeamView Answer on Stackoverflow
Solution 10 - React NativeYusuf GüvençliView Answer on Stackoverflow
Solution 11 - React NativeSadidul IslamView Answer on Stackoverflow
Solution 12 - React NativeNikolaView Answer on Stackoverflow
Solution 13 - React NativeMertcan SeğmenView Answer on Stackoverflow
Solution 14 - React NativeMollyView Answer on Stackoverflow
Solution 15 - React NativeFunda EseView Answer on Stackoverflow
Solution 16 - React NativeSiddy HacksView Answer on Stackoverflow
Solution 17 - React NativeMichgolden UkejeView Answer on Stackoverflow
Solution 18 - React NativeStefanView Answer on Stackoverflow
Solution 19 - React NativeParveen ChauhanView Answer on Stackoverflow
Solution 20 - React NativeGordon developerView Answer on Stackoverflow
Solution 21 - React NativeVladimir SalgueroView Answer on Stackoverflow
Solution 22 - React Nativeuser1462498View Answer on Stackoverflow
Solution 23 - React NativecrispengariView Answer on Stackoverflow
Solution 24 - React NativeMateus FlowinTechView Answer on Stackoverflow
Solution 25 - React NativeMikeLView Answer on Stackoverflow
Solution 26 - React NativeHend El-SahliView Answer on Stackoverflow
Solution 27 - React NativeAnatuGreenView Answer on Stackoverflow
Solution 28 - React NativeDavid JonesView Answer on Stackoverflow
Solution 29 - React NativeCarlos VallejoView Answer on Stackoverflow
Solution 30 - React NativeFotios TsakirisView Answer on Stackoverflow
Solution 31 - React NativeGiteshView Answer on Stackoverflow
Solution 32 - React NativeDevView Answer on Stackoverflow