I'm new to react native and trying to set up the environment before I start coding. Whenever I try to run the command: 'react-native run-android', it throws an error:
Failed to launch emulator. Reason: No emulators found as an output of emulator -list-avds.
I'm following the documentation but still getting the error. How do I fix this?
you should add JAVA_HOME to windows environment variables, try to install Java SE Development Kit (JDK) with Chocolatey or download from https://openjdk.java.net/projects/jdk8/
if doesn't work:
Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1, Apply and close Properties, now it works
you can use AndroidStudio for open emulator , after open emulator you can use react-native run-android , after app installed you can use react-native start for more time.
you most install JDK for run java, and set JAVA_HOME in Environment Variables.
Set the JAVA_HOME Variable
To set the JRE_HOME or JAVA_HOME variable:
1.Locate your Java installation directory
If you didn't change the path during installation, it'll be something like C:\Program Files\Java\jdk1.8.0_65
You can also type where java at the command prompt.
2.Do one of the following:
Windows 7 – Right click My Computer and select Properties > Advanced
Windows 8 – Go to Control Panel > System > Advanced System Settings
Windows 10 – Search for Environment Variables then select Edit the system environment variables
3.Click the Environment Variables button.
4.Under System Variables, click New.
5.In the Variable Name field, enter either:
JAVA_HOME if you installed the JDK (Java Development Kit)
or
JRE_HOME if you installed the JRE (Java Runtime Environment)
6.In the Variable Value field, enter your JDK or JRE installation path .
for more see this link this
Related
I am trying to install android sdk through command line tools, in most of the tutorials it says that I should run android.bat from tools folder but cmd opens and then closes after a second or two, so I tried with the sdkmanager.bat from tools\bin\sdkmanager.bat but the same happens.
I googled and found some information so I tried running it from cmd, android.bat is deprecated it says, but when running sdkmanager.bat or avdmanager.bat it gives me an error: JAVA_HOME is not set
Here is the screenshot:
I tried following the steps as in: How to set java_home on Windows 7?
But after I did it and tried running it again in cmd, my problem is now this:
To Set JAVA_HOME in Windows:
Right click My Computer and select Properties.
On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for
example, C:\Program Files\Java\jdk1.8.0_161\
If you don't have JDK software.
Go to http://java.sun.com/javase/downloads/index.jsp.
Select the appropriate JDK software and click Download.
I set the android_sdk_home variable so that my application could find .android when trying to run. Now I get an error stating that "android_sdk_root is undefined".
I am running win 7 with a new installation of Android Studio, inside parallels on a macbook pro.
Thank you for your response. I checked the location and it is identified as the same location as the ANDROID_SDK_HOME environment path. It still says root is undefined. I created an ANDROID_SDK_ROOT enviroment path to the same location and it is still undefined.
This is how I did it on macOS:
vim ~/.bash_profile # macOS 10.14 Mojave and older
vim ~/.zshrc # macOS 10.15 Catalina and newer (using zsh by default)
And added the following environment variables:
export ANDROID_HOME=/Users/{{your user}}/Library/Android/sdk
export ANDROID_SDK_ROOT=/Users/{{your user}}/Library/Android/sdk
export ANDROID_AVD_HOME=/Users/{{your user}}/.android/avd
Android path might be different, if so change it accordingly. At last, to refresh the terminal to apply changes:
source ~/.bash_profile # macOS 10.14 Mojave and older
source ~/.zshrc # macOS 10.15 Catalina and newer (using zsh by default)
I received the same error after installing android studio and trying to run hello world. I think you need to use the SDK Manager inside Android Studio to install some things first.
Open up Android Studio, and click on the SDK Manager in the toolbar.
Now install the SDK tools you need.
Tools -> Android SDK Tools
Tools -> Android SDK Platform-tools
Tools -> Android SDK Build-tools (highest version)
For each Android release you are targeting, hit the appropriate Android X.X folder and select (at a minimum):
SDK Platform
A system image for the emulator, such as ARM EABI v7a System Image
The SDK Manager will run (this can take a while) and download and install the various SDKs.
Inside Android Studio, File->Project Structure will show you where your Android sdks are installed. As you can see mine is c:\users\Joe\AppData\Local\Android\sdk1.
If I navigate to C:\Users\Joe\AppData\Local\Android\sdk1\sources you can see the various Android SDKs installed there...
Open the terminal and run the command:
nano $HOME/.bashrc
aggregate the follow line:
export ANDROID_HOME=$HOME/Android/Sdk
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Ctrl+o save and ctrl+x close.
And run the command:
source $HOME/.bashrc
echo $ANDROID_SDK_ROOT
MAC - one liner
echo "export ANDROID_HOME=~/Library/Android/sdk \
export ANDROID_SDK_ROOT=~/Library/Android/sdk \
export ANDROID_AVD_HOME=~/.android/avd" \
>> ~/.bash_profile && source ~/.bash_profile
android_sdk_root is a system variable which points to root folder of android sdk tools.
You probably get the error because the variable is not set.
To set it in Android Studio go to:
File -> project Structure into Project Structure
Left -> SDK Location
SDK location select Android SDK location
If you have installed android SDK please refer to this answer to find the path to it: https://stackoverflow.com/a/15702396/3625900
In addition to the above answers, ANDROID_HOME, which also points to the SDK installation directory, is deprecated.
If you continue to use it, the following rules apply:
If ANDROID_HOME is defined and contains a valid SDK installation, its value is used instead of the value in ANDROID_SDK_ROOT.
If ANDROID_HOME is not defined, the value in ANDROID_SDK_ROOT is used.
If ANDROID_HOME is defined but does not exist or does not contain a valid SDK installation, the value in ANDROID_SDK_ROOT is used instead.
You need to make a system env variable with the name: ANDROID_SDK_ROOT
and it's value should be C:\Users\your_user_name\AppData\Sdk\tools\bin
worked for me
ANDROID_HOME
Deprecated (in Android Studio), use ANDROID_SDK_ROOT instead.
ANDROID_SDK_ROOT
Installation directory of Android SDK package.
Example: C:\AndroidSDK or /usr/local/android-sdk/
ANDROID_NDK_ROOT
Installation directory of Android NDK package. (WITHOUT ANY SPACE)
Example: C:\AndroidNDK or /usr/local/android-ndk/
ANDROID_SDK_HOME
Location of SDK related data/user files.
Example: C:\Users\<USERNAME>\.android\ or ~/.android/
ANDROID_EMULATOR_HOME
Location of emulator-specific data files.
Example: C:\Users\<USERNAME>\.android\ or ~/.android/
ANDROID_AVD_HOME
Location of AVD-specific data files.
Example: C:\Users\<USERNAME>\.android\avd\ or ~/.android/avd/
JDK_HOME and JAVA_HOME
Installation directory of JDK (aka Java SDK) package.
Note: This is used to run Android Studio(and other Java-based applications). Actually when you run Android Studio, it checks for JDK_HOME then JAVA_HOME environment variables to use.
For macOS with zshrc:
ANDROID_HOME is depreciated, use ANDROID_SDK_ROOT instead
Ensure that Android Build Tools is installed. Check if it exists in your File Directory
Get the path to your SDK. Usually it is /Users/<USER>/Library/Android/sdk
Add ANDROID_SDK_ROOT as a path to your Environment variables:
echo 'export ANDROID_SDK_ROOT=/Users/<USER>/Library/Android/sdk' >> ~/.zshenv
Apply the changes with source ~/.zshrc
Check if it was saved by ...
... checking the specific environment variable echo $ANDROID_SDK_ROOT
... checking the complete list of environment variables on your system env
You can apply this process to every environment variable beeing installed on your macOS system. It took me a while to comprehend it for myself
on Mac edit .bash_profile use code or vim
code ~/.bash_profile
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_HOME=~/Library/Android/sdk
In Android Studio 3.2.1 I got this error because I installed a new API(28) level emulator without installing that API SDK components. After I installed SDK platform and SDK platform tools for the API level 28 and updated Android Emulator the emulator started running.
Hope it may help someone.
This is how to change it :
Step 1 :
Open a Terminal / CMD As Administrator (Right-click on cmd and click "Run as Administrator")
Step 2:
type in " set ANDROID_SDK_ROOT=E:\Android\sdk\ " (type it without the quotes and replace "E:\Android\sdk" with your actual sdk file path location - Mine was : C:\Users\YOUR_ACCOUNT\AppData\Local\Android\Sdk
step 3:
Press "Enter" and i noticed nothing happened
Step 4:
Build your app again and it should reflect your file path.
For me it doisplayed as :
Preparing Firebase on Android
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=C:\Users\Kurt\AppData\Local\Android\Sdk (recommended setting)
ANDROID_HOME=C:\Users\Kurt\AppData\Local\Android\Sdk (DEPRECATED)
Subproject Path: CordovaLib
Subproject Path: app
I got that info from this site :
https://developer.android.com/studio/command-line/variables#android_sdk_root
Check it out for more information
Have Fun!!
I followed this tutorial to set up my android environment variables I was on mac and I had all the required environmental variable setup and working already. but i was still getting this error that requires environment ANDROID_SDK_ROOT.
I already had an android SDK exported environment variable.
So, what I simply did is adding ANDROID_HOME to the path with the following commands:
export PATH=$PATH:$ANDROID_HOME
and it worked for me on macOS
on mac os
you can try
brew install gradle
A common mistake that people tend to make when setting the root is capitalization errors in the path, or accidental spacing. Hence, I would recommend you check that. If that does not solve it, then check if the folder you are linking to still exists, or was accidentally moved into the trash.
I am getting this error in terminal when attempting to execute this command:
$ cordova platform add android
I read these answers here:
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions
ANDROID_HOME is not set and "android" command not in your PATH Phonegap
however I don't know where to place the code they provide.
I am running OS X.
Option 1
for windows
Right click on My computer -> properties -> Advanced system setting -> Environment Variables
Now Edit Path on system variables to
;/yourSdkHome/tools;/youSdkHome/platform-tools
Option 2
In Windows machine, Open Command prompt and enter each of this commands one by one
set ANDROID_HOME=**C:\\android-sdk-windows**
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
In MAC Machine, open Terminal and enter these one by one
export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Note - C:\\android-sdk-windows should be replaced by the path of Android SDK in your machine.
<installation location> should be replaced by the path of Android SDK in your machine.
Example
in MAC machine, if install location is ~/adt-bundle-mac-x86_64/sdk
first line should be
export ANDROID_HOME=~/adt-bundle-mac-x86_64/sdk
I am new to Android's uiautomator testing framework: http://developer.android.com/tools/testing/testing_ui.html
I am trying to build the hello-world example described in section "A sample uiautomator test case". When I proceed to step 3 (running "ant build"), I got following error
Error: Could not find or load main class Files\Java\jdk1.7.0_55\lib\tools.jar;C:
\Users\xxx\AndroidHacker\tools\jakarta-ant-1.5.1\bin\..\lib\xml-apis.jar;C:\U
sers\xxx\AndroidHacker\tools\jakarta-ant-1.5.1\bin\..\lib\xercesImpl.jar;C:\U
sers\xxx\AndroidHacker\tools\jakarta-ant-1.5.1\bin\..\lib\optional.jar;C:\Use
rs\xxx\AndroidHacker\tools\jakarta-ant-1.5.1\bin\..\lib\ant.jar;
Can anyone see the problem?
Jeff,
Verify if the file tools.jar exists in the path Files/Java/jdk1.7.0_55/lib/.
If it doesn't, maybe you've installed only Java JRE and then you need to download and install the JDK version. That's necessary because the JRE version doesn't contain the compiler and some libraries, like tools.jar.
Link to download JDK: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Otherwise, I would recommend you verify the enviroment varible JAVA_HOME with the following command in cmd:
echo %JAVA_HOME%
It must point to the path where your JDK is installed. In my case it's
C:\Program Files (x86)\Java\jdk1.7.0_60
In case you want to edit the path, you can use the command setx:
setx JAVA_HOME=Path_to_your_sdk
Or go to Control Panel > System and Security > System > Advanced System settings > Environment Variables, then modify the value of the variable JAVA_HOME at "User variables" to the sdk path.
I'm trying to get the new GCM service to work for me, so I've been following the demo as described here: http://developer.android.com/guide/google/gcm/demo.html
So far, everything works well. However, I'm supposed to build the ant files using the command line now, and that's where things stop working.
For some reason, this command $ android update project --name GCMDemo -p . --target android-16 gives me a very nice
'android' is not recognized as an internal or external command,
operable program or batch file.
Normally this can be fixed easily with a quick Google search, but I haven't found a single other user with this problem. Could someone tell me what the problem is?
My educated guess is that I need to add the Android tools folder to my PATH, but I'd rather be sure first.
Your guess is correct, just add the folder containing android.bat(tools folder) to the PATH. Otherwise the system will not be able to find the program.
Other possibility is change directory (using cd) to the tools folder, and execute the command from there. Since the current directory (whatever it is) is usually in the PATH, the system will find it. But this is not handy, because you frequently want to execute this command being in a different directory.
Find android.bat on your system. On mine (win 8 x64) it's under C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat
Open a command console, and use the 'doskey' command:
doskey android=C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat $*
This will continue to work in the open command console. To make it permanent is more difficult: http://darkforge.blogspot.com/2010/08/permanent-windows-command-line-aliases.html
You can also try adding it to your PATH as another poster suggested, but that didn't work for me. I recommend an easy gui for doing it, such as https://patheditor2.codeplex.com/
In Windows 7, navigate to
Control Panel\System and Security\System > advance system settings > environment variables
and update the path to include the following:
<android-root>\android-sdk-windows\tools
Use semicolons to separate paths if more than one exist.
On Windows 10, add both:
C:\Users\Parag Jain\AppData\Local\Android\sdk\tools
C:\Users\Parag Jain\AppData\Local\Android\sdk\build-tools
to the PATH environment variable of System and User. Make sure that you close your command prompt and restart a new prompt and then try the command.
Compiling previous answers I did the following to get Android SDK and gradle working (You need gradle working anyway to compile your Android project):
Prerequisites. You have Java jdk, Android SDK and gradle installed in the folders like I found on my computer. Please, check it:
C:\Program Files\Java\jdk1.X.X_XX\
C:\Users{username}\AppData\Local\Android\sdk\
C:\Program Files\Android\Android Studio\gradle\gradle-X.X\
Set up three new system variable (Control Panel\System and Security\System Advance system ->settings->environment variables-system variables). Do not forget to change java and gradle versions.
JAVA_HOME C:\Program Files\Java\jdk1.X.X_XX
ANDROID_HOME C:\Users\{username}\AppData\Local\Android\sdk
GRADLE_HOME C:\Program Files\Android\Android Studio\gradle\gradle-X.X\
Add the following paths to system paths (Control Panel\System and Security\System Advance system ->settings->environment variables-system variables):
%JAVA_HOME%
%ANDROID_HOME%\tools\
%ANDROID_HOME%\platform-tools
%GRADLE_HOME%\bin
Close and open once again your Dos application (Cmd terminal, etc.). You might want to REBOOT your computer, to make sure, that the system sees the variables. If you do not want to reboot, you can use the advice of #wordsforthewise
doskey android=C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat $*
Check if Android SDK and gradle work properly with the terminal commands
$ java -version
$ android list target
$ gradle -v
What worked for me:
Setting up the ANDROID_HOME variable as a System variable instead of a user variable.
I am using Windows 10, not sure if that matters.
I resolved this issue permanently using the below steps.
OS version : windows 7 64 bit
Solution : Set environment variable for android sdk and gradle
Step 1: Create new "ANDROID_HOME" User Variable
Variable Name: ANDROID_HOME
Variable Value C:\Users{user_name}\AppData\Local\Android\sdk\
Step 2: Create new "GRADLE_HOME" User Variable
Variable Name: GRADLE_HOME
Variable Value C:\Program Files\Android\Android Studio\gradle\gradle-x.x\
*Do not forget to change and gradle versions.
Step 3: Create "ANDROID_HOME" System Variable
Variable Name: ANDROID_HOME
Variable Value C:\Users{user_name}\AppData\Local\Android\sdk\
Step 4: Create new "GRADLE_HOME" System Variable
Variable Name: GRADLE_HOME
Variable Value C:\Program Files\Android\Android Studio\gradle\gradle-x.x\
*Do not forget to change and gradle versions.
Reopen the command prompt and confirm below command output :
1. gradle -v
2. android list target