I'm trying to run our react native app in Android emulator, after yarn android the Emulator starts but the app doesn't and after a few seconds I get the following error:
yarn run v1.22.10
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1755 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Launching emulator...
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: spawn ./gradlew EACCES
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The project runs perfectly in XCode (ios), also in my colleague's laptop (with Windows).
I'm using a Macbook Air m1, macOS 11.3.1, SDK Platform: Android S, Android Studio 4.2.2, yarn version v1.22.10, node v15.12.0,
Here might be a react-native configuration issue with the current development environment on your system.
Please have a close look at the official docs to set up the environment.
React native Docs
First of all, make sure you have your Android Environment setup correctly.
To verify run
echo $ANDROID_HOME
echo $PATH
and make sure both have the correct path to your Android SDK.
If it's not correct, you have to set up your Android Environment
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
Reference react-native-official-setup-guide
Other than that, the major issue which I see is related to Macbook Air M1, I just face a similar issue, M1 doesn't support VT-X.
To make sure that, your Macbook Air M1 supports VT-X open Android Studio and then AVD Manager.
Example (My Macbook) (Marked in PURPLE Box, VT-X is not supported)
Solution to this:
Download new emulator from android-emulator-apple-silicon-preview
This should enable developers to test/run ARM64 apps via ARM64 hardware virtualization.
For the "Error: spawn ./gradlew EACCES at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)".
Please try to input:
chmod 755 android/gradlew
in the root directory of the project. Then:
npx react-native run-android
Related
Hello friends pls I have been stuck on this 😔 error for the past weeks I'm trying to run a React native cli project on my Windows laptop and after following the documentation on the official create React native website I still get this error I have already downloaded and installed my android studio and my virtual device is up and running but for some reason I whenever I try to run "npx react-native run-android " after a while this error shows up
This my first working on a React native cli project
I ran npx react-native init app3
And
I have configured my Path and Android_Home environment variables as you can see it's still showing on my command prompt and powershell
I'm using a
Node version 16.13.0
Npm version 8.1.0
Javac version 17.0.1
And I'm relatively new to mobile development
Is used the the
Echo %ANDROID_HOME%
echo %PATH%
Command to check the Android_Home And Path location on my system
And it was as follows
C:\Users\andre\AppData\Local\Android\Sdk
C:\Users\andre\AppData\Local\Android\Sdk\platform-tools
Im Using MacBook Pro.. Im New To React Native.. After Creating An Project Im Running On iOS Device It's Running.. At The Same Time While I'm Running On Android Device Means Im Getting This Error.. Any One Please Help Me To Resolve This Error.. Im Using Visual Studio Code IDE For React Native Application
Thanks In Advance..
Error Details :
[Info] local.properties file doesn't exist. Using Android SDK location from PATH.
[Info] Starting React Native Packager.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 8 workers...
/bin/sh: adb: command not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
FAILURE: Build failed with an exception.
* Where:
Settings file '/Users/manikandan/AwesomeProject/android/settings.gradle'
* What went wrong:
Could not compile settings file '/Users/manikandan/AwesomeProject/android/settings.gradle'.
startup failed:
General error during semantic analysis: Unsupported class file major version 57
So you have two errors to fix here as your error log
local.properties file doesn't exist.
Failed to launch the emulator
local.properties file issue fixing
Open your react native project android folder using Android Studio.
Wait for gradle sync and clean the project and rebuild it using Android Studio
After that make sure you have local.properties file is been created inside android folder
If not try these steps to make local.properties file manually
Right click top level of project and Create new file 'local.properties' then add: sdk.dir=/Users/<YourUsername>/Library/Android/sdk
Clean and build
Before running your react native project on android make sure you have turn on the Android Emulator by AVD Manager in Android Studio
If you have not create any emulators then try this link - I have posted full answer on how to make Android Emulator -
React native failed to launch emulator
EDIT :
For adb error you need to install adb drivers on you Mac
Follow these steps
First install Homebrew using this command
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
or this command
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
After that install adb using homebrew
brew cask install android-platform-tools
Try to re run
I'm trying to create a React Native app for Android. I use bash from the command line in Windows 10. I browse to the location of my React Native project and then run "react-native run-android". But then I get an error like this:
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
/bin/sh: 1: adb: not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
at checkExecSyncError (child_process.js:601:13)
at execFileSync (child_process.js:621:13)
at runOnAllDevices (/mnt/c/users/lenovo/documents/repositories/upself rn/upself/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
TL;DR it tells me to set the environment variable for JAVA_HOME. AFAIK.
The problem is I've already set the JAVA_HOME since I installed the Windows 10 in my laptop which was months ago. I use JDK 12 and have developed few native Android app using Android Studio using this same laptop and never have I encountered any missing JAVA_HOME issue.
This is what I've tried to try to solve this issue:
Run the cmd as administrator
Set the JAVA_HOME to c:\Program Files\Java\jdk-12.0.2\ and the one in Android Studio default SDK location C:\Users\lenovo\AppData\Local\Android\Sdk. Both dont work.
Restart my laptop and cmd (done it multiple times but it still doesnt work).
Put a quotation mark between the path (found this in a stack overflow question).
I've read many questions in stack overflow but none of those works.
So, could anyone help me to solve this problem? Why is it unable to detect the environment path?
According to react native document, you should install just JDK 8 for running react native app
https://facebook.github.io/react-native/docs/getting-started
after installing java and set the environment variable, you must reboot your system.
https://www.thewindowsclub.com/set-java_home-in-windows-10
I installed android studio, I configured the environment variables and everything, I installed genymotion and created a device, but running the react-native run-android in the project folder occurs the following error:
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.
please help me in this problem. React-native does not find Genymotion disositivo, in this link has more details: https://pt.stackoverflow.com/questions/382115/react-native-n%C3%A3o-reconhece-genymotion
It tries to connect the emulator to the ADB, by the IP of the device. To check the IP of the device, simply click on an emulator window, the IP address is in the title of the window.
No terminal will run the command:
$ adb connect ip_of_your_emulator:5555
Soon after, run:
$ adb devices
If the name of your file appears in the list, your emulator has been connected successfully!
With the emulator open, simply run the native run-android in the folder of your project.
I've had the same problem earlier this month. As far as I can tell the newer versions of Genymotion don't register on adb devices, a user in the Expo forums speculates it's because they have a paywall now.
I recommend switching to Android Studio, that's what I did to solve my problem.
I ran react-native with the --verbose flag, and got the following error:
...
error Failed to install the app. Make sure you have the Android development
environment set up: https://reactnative.dev/docs/environment-setup.
Error: spawn ./gradlew EACCES
...
So, I gave permissions to the android/gradlew folder as follows:
chmod 755 android/gradlew
But then, I got an error regarding Google Play Licenses:
error Failed to install the app. Please accept all necessary Android SDK
licenses using Android SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses".
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
So yeah, pretty the solution was:
Downloading Android Studio with its own SDK
Change the env variabe ANDROID_HOME to the one installed with Android Studio
Installing Google Play Licensing Library (In Android Studio, go to Settings>SDK Manager>SDK Tools, select Google Play License Library and then install)
I am using Ubuntu 14.04 version and im trying to work with ionic.
The error comes when I try to:
$ ionic start todo blank
$ cd todo
$ sudo ionic platform add android
$ sudo ionic build android
And I get the following error:
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
ERROR building one of the platforms: Error: /home/kelvin/Desktop/todo/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/kelvin/Desktop/todo/platforms/android/cordova/build: Command failed with exit code 2
I know there is alot of sites with a answer to this question, but none of them gave me a fix. Or maybe they did, but I didnt understand it. I tried on this site building-ionic-app, but that didnt work either.
I followed this tutorial by Nic Raboy, and its still not working.
Install Android, Cordova, and Ionic Framework in Ubuntu.
So let me explain what I did and maybe that is helpfull to fix my problem:
I started with this guide: Ionic Framework Guide
To install Cordova, make sure you have Node.js installed, then run
Install Node.js
$ sudo apt-get install -y nodejs
$ node -v
v5.0.0
Install Cordova
$ sudo npm install -g cordova
Follow the Cordova platform guides for Android and iOS to make sure you have everything needed for development on those platforms.
Follow the Cordova platform guides for Android
I followed this guilde:
Complete installing guide for android SDK / ADT Bund on Ubuntu
My computer is 64-bit and since im using 14.04.
Step 2: install libgl1-mesa-dev:i386 package.
$ sudo apt-get install libgl1-mesa-dev:i386
Step 3: Install openjdk-6-jdk or better, openjdk-7-jdk
$ sudo apt-get install openjdk-7-jdk
Step 4: Download the Android SDK or the ADT Bundle from here and unzip it to wherever you want.
Then I follow step 4 on techtach Complete Guide
$ wget http://dl.google.com/android/android-sdk_r20-linux.tgz
$ wget http://dl.google.com/android/adt/22.6.2/adt-bundle-linux-x86_64-20140321.zip
Then I unzipped the adt-bundle and copied the folders from SDK -> /home/kelvin/android-sdk-linux/
The folders are: build-tools,extras,platforms,platform-tools,system-images,tools.
Then I executed the following command to install latest android updates
$cd ~/android-sdk-linux/tools
$sudo ./android
And installed
Android SDK Tools (24.0.2)
Android SDK Platform-tools (20)
ANDROID SDK Build-tools (19.0.3)
SDK Platform
ARM EABI V7a System Image
Android Support Library
And then open bashrc
$gedit ~/.bashrc
And added the following lines.
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
export ANDROID_HOME=~/android-sdk-linux/tools
Checking if it is right:
$ANDROID_HOME
bash: /home/kelvin/android-sdk-linux/tools: Is a directory
Create the project & Configure Platforms
$ ionic start todo blank
$ cd todo
$ sudo ionic platform add android
$ sudo ionic build android
And I get the following error:
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
ERROR building one of the platforms: Error: /home/kelvin/Desktop/todo/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/kelvin/Desktop/todo/platforms/android/cordova/build: Command failed with exit code 2
And now im kinda lost. I found a forum where they have the same problem: ANDROID_HOME is not set... and one of the guys suggested.
I finally solved it. It was on my users path but not the root users path. I have to run these commands as a root user. I had to edit my root users .bash_profile file.
and one of the others tells how:
In Ubuntu, do all the commands also root
sudo su
gedit ~/.bash_profile
export ANDROID_HOME=/root/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
But a third guy said this is a bad idea, so I didnt do it.
I can run the following command:
$ionic serve
And it runs in the browser, but I cant run for android.
I just read your question and it seems you followed the correct way.I faced the same situation during installation process.
The proper set up an Ubuntu machine for Ionic Framework Android development has many steps.Now there are a ton of options to handle this task, but not many bare bones solutions. Most solutions on the internet explain how to use an IDE, or fail to elaborate a complete installation.
After a research,I have found a nice tutorial by Nic Raboy.I followed this tutorial and everything is fine now.
Install Android, Cordova, and Ionic Framework in Ubuntu