After typing cordova run android in terminal, I'm getting this error:
Waiting for emulator to start...
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/Users/username/Library/Android/sdk]!
This happens after exporting:
export ANDROID_SDK_ROOT='/Users/username/Library/Android/sdk'
Before exporting I got:
Waiting for emulator to start...
PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT
Any ideas where I'm going wrong? I'm sure this is the sdk root so why am I getting broken avd system path?
There are may be several different problems when you move your AVD or SDK to another directory, or replace an old SDK with a new one, or somehow get the SDK corrupted.
Below I'll describe all the possible problems I know, and will give you several ways to solve them.
Of course I assume that you have any AVD created, and it is located in C:\Users\<user_name>\.android\avd (Windows) or ~/.android/avd (Linux/MacOS).
If you moved .android to another place then set the ANDROID_SDK_HOME environment variable to the path of the parent dir containing your .android and make sure the AVD Manager successfully found your Virtual Device.
Also check paths in <user_home>/.android/avd/<avd_name>.ini
Incomplete/corrupted SDK stucture
PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value
These 2 errors happen if the emulator cannot find the SDK, or the SDK is broken.
So, first of all I recommend to remove the ANDROID_SDK_ROOT variable at all. It's only needed when the emulator is located outside of the SDK directory. But in general, your emulator stays inside the SDK dir. And in this case it must detect the SDK location automatically. If it doesn't, then your SDK probably has wrong filetree. Please do the following:
Check that the SDK directory has at least these 4 directories: emulator, platforms, platform-tools, system-images. It is very important! These directories must be present. If some of them don't exist, then just create empty dirs.
Go to <user_home>/.android/avd/<avd_name> and open config.ini. Find the image.sysdir.1 property. It points at the directory, inside the SDK directory, that contains the actual system image. Make sure that this directory exists and contains files like build.prop, system.img, etc. If it doesn't, then you have to open the SDK Manager and download system images your AVD requires (see below).
If everything's set up properly, when these errors about ANDROID_SDK_ROOT must be gone. If they're not, then now you may try to set up ANDROID_SDK_ROOT variable.
Required packages and HAXM are not installed
The next problem you may face is that the emulator starts to launch, but hangs up or quits immediatelly. That probably means that you don't have all the required packages installed.
Another possible error is:
Could not automatically detect an ADB binary. Some emulator functionality will not work until a custom path to ADB is added in the extended settings page.
So, to successfully launch any AVD you must be sure that at least these packages are installed:
emulator (Android Emulator)
platform-tools (Android SDK Platform-Tools)
tools (Android SDK Tools)
And as I mentioned earlier you must install system images your AVD is using, for example system-images;android-25;google_apis;x86
Note that the most recent versions on SDK don't have a standalone SDK Manager.exe. Instead of it you have either to use Android Studio, or tools\bin\sdkmanager.bat (Linux/MacOS probably have sh files).
To list all available packages use sdkmanager --list or sdkmanager --list --verbose
To install packages use sdkmanager <package1> <package2> ...
Also I recommend to install HAXM on your system manually.
Qcow2-files refer to incorrect/nonexistent base-images
The last problem I'll mention happens when you're trying to move AVD or SDK from one computer or directory to another. In this case you may get such error:
qemu-system-i386.exe: -drive if=none,overlap-check=none,cache=unsafe,index=0,id=system,file=C:\Users\<old_user_name>\.android\avd\<avd_name>.
avd\system.img.qcow2,read-only: Could not open backing file: Could not open '<old_sdk_dir>\system-images\android-22\google_apis\x86\system.img': Invalid argument
There are 2 ways to fix it:
If you don't care about the data the AVD contains, just delete all the qcow2 files from the AVD directory (e.g. from <user_home>/.android/avd/<avd_name>). In this case you will get a clean version of Android, like after a hard reset.
If the data on the emulator is important to you, then open all qcow2 files one by one using any HEX editor (I prefer HxD), find the path of a base img file, and change it to the correct one in the Overwrite mode (to preserve the file size). Then select the path and get its length in hex (e.g. 2F). 2F represents the ASCII slash /. Put it into position 13:
PS: Not sure, but there are probably some utilites like qemu-img allowing to set different base image. Well, to me it's easier to manually edit the binary.
Now you'll probably be able to successfully launch your Android Virtual Device. I hope so :)
On Mac:
I had installed android-sdk using brew as well as Android Studio. Somehow, having 2 installations was causing this problem. When I uninstalled my brew installation of the sdk using brew cask uninstall android-sdk and added the following vars to my env. It worked.
export ANDROID_HOME=/Users/<Username>/Library/Android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
This will solve your problem in macOS:
pico ~/.bash_profile
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export ANDROID_SDK_HOME=/Users/$USER/Library/Android/sdk
export ANDROID_AVD_HOME=/Users/$USER/.android/avd
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_AVD_HOME
source ~/.bash_profile
It means that your path to tools is incorrect. This is what it looks like on a mac using brew. Mind the version.
export ANDROID_SDK_ROOT='/usr/local/Cellar/android-sdk/24.4.1_1'
In your case it looks like you should run this:
export ANDROID_SDK_ROOT='/Users/username/Library/Android/sdk'
Removing the Error While Using Homebrew's Android SDK as the Default SDK
As #EFreak did I installed the android-sdk with homebrew (a package manager for Macs). I needed to do the below to fix the error, because I was following the nativescript tutorials and ran into the error. If you like me intend to use the brew version over the android-sdk version use this answer (this will allow you to use nativescripts tns run android api), and if you want the android studio default android-sdk follow #EFreak's answer.
Configuring Android Studio to use the Homebrew's Android SDK's
Basically you just need to change your Android SDK location in Android studio. First open a project in android studio. Then open the SDK Manager by clicking this button.
Next when the default preferences for the android SDK manager comes up you need to click edit next to the android SDK location.
Finding the Location of Homebrew's Android SDK
Next you need to actually update the sdk location on the sdk components setup screen my brew android-sdk was located here /usr/local/share/android-sdk. You can find where yours is installed by running brew cask info android-sdk then near the bottom of the output it should say:
You can control android sdk packages via the sdkmanager command.
You may want to add to your profile:
'export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"'
The value of the exported ANDROID_SDK_ROOT variable (which here is /usr/local/share/android-sdk) is home-brew's location of the android sdk.
Then you need to click the Android SDK Location button (labeled as 1 in the picture) and paste in Homebrew's Android SDK location.
Then just finish up the wizard by installing whatever packages. I needed to delete and recreate my device emulators at this step, but it seemed to work great after that.
Setting the Android SDK Environment Variables to Point to Homebrew's Android SDK
Also you may want to make sure if you are going the Homebrew route that your profile settings script has the ANDROID_HOME and ANDROID_SDK_ROOT environment variables set to your Homebrew location of the android sdk otherwise the above won't work yet. This can get changed from the Homebrew location if you installed Homebrew before installing Android Studio as pointed out in this answer by #Jamie Armour. You can check the environment variables for the android sdk are set correctly by running echo $ANDROID_HOME and echo $ANDROID_SDK_ROOT and verifying that they both show the Homebrew location of the android sdk.
If you need to change the ANDROID_HOME and ANDROID_SDK_ROOT values you can do this in your profile settings in your Mac which would likely be in something like ~/.bash_profile, "~/.bashrc", or "~/.profile" and defined like so:
export ANDROID_HOME="/usr/local/share/android-sdk"
export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"
You need to change the values of both the exports to the proper values of Homebrew's android SDK location then save the file. To verify that the right values have been written you should first either close and open your terminal which should rerun the file and reset the environment variables or you can source the file by running source <profile file name> where is the profile file you edited and saved. You then can rerun echo $ANDROID_HOME and echo $ANDROID_SDK_ROOT to verify that they have the Homebrew android sdk location.
I had same problem in my Windows10,
Isolved my problem by following the steps below.
open Android Studio
- Tools
- SDK Manager
- copy Android SDK Location
Android SDK Location
set system environment variable
ANDROID_HOME and ANDROID_SDK_ROOT
system environment variable
I had the same issue after emulator update. Problem was resolved after adding variable ANDROID_AVD_HOME
Important: Non-ASCII characters cannot be used in the path.
Finally reinstall virtual devices or manually override device path in Configuration settings.ini file which contains old path with non-ascii characters.
C:\Users\<user_name>\.android\avd\<avd_name>
Platfoms directory was missing in /usr/local/share/android-sdk.
I created an empty directory named platforms that fixed the issue.
In my case it was broken because ANDROID_HOME and ANDROID_SDK_ROOT were different, so once I set ANDROID_HOME to be the same as ANDROID_SDK_ROOT then it started working.
I ran Android Studio on Windows 10, set ANDROID_HOME and ANDROID_SDK_ROOT on Environment Variables, and still got the error.
Turns out, I forgot to download the device.
After downloading the "Missing system image", everything works fine.
Oleg Cherrs answer led me to a solution. As he mentioned
Go to /.android/avd/ and open config.ini. Find the >image.sysdir.1 property. It points at the directory inside SDK containing system >images. Make sure that this directory exists and contains files like build.prop, >system.img, etc. If it doesn't, then you have to open the SDK Manager and >download system images your AVD requires (see below).
I found the corresponding emulator *.ini file in the avd directory.
There I modified the "image.sysdir.1" entry. I replaced the relative with an absolute path (append the ANDROID_SDK_ROOT in front). After that the emulator started from the command line as expected.
I'm in Windows 10 and the problem was that the avd's directory in my computer had non-ASCII characters in it.
Here's what to do:
Run cmd as administrator
Run the following command:
mklink /D C:\\.android C:\\Users\\-yourUsername-\\.android
(This will create a symbolic link between the path with non-ASCII characters and the new one)
In enviroment variables add ANDROID_AVD_HOME variable with value C:\\.android\avd.
A fix if your user contains non-ASCII characters
For people getting "PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT", the reason for this might be that your user in users contains non-ASCII characters.
Therefore both the SDK and .android folder with the AVD folder need to be moved to another folder.
Changing the SDK path:
Open Android Studio, go to configure, and choose the SDK Manager. Change the current Android SDK Location to e.g "C:\Android\Sdk" (Or somewhere else, just not in the user folder containing non-ASCII characters).
After this, add the following system variables:
ANDROID_SDK_ROOT C:\Android\Sdk
ANDROID_HOME C:\Android\Sdk
Changing the AVD path:
To change where the AVD folder is placed (Normally placed in "C:\Users\<user name>\.android\avd"), you need to change where the .android is placed. First close Android Studio, then add the system variable ANDROID_SDK_HOME with the path to the new place you want .android to be, e.g C:\Android_SDK_HOME as used in another example:
ANDROID_SDK_HOME C:\Android_SDK_HOME
After you added this, run Android Studio. Then close it again. Now a folder called .android should have appeared.
The next and last thing you need to do is to set the ANDROID_AVD_HOME system variable. In this case that will be in C:\Android_SDK_HOME\.android\avd
ANDROID_AVD_HOME C:\Android_SDK_HOME\.android\avd
I hope this resolves the problem for some. :)
ok i can run android from cordova, i changed ANDROID_HOME to,
export ANDROID_HOME=/usr/local/opt/android-sdk
You should add AVD Emulator.
Go to this location:
C:\Users\%username%\AppData\Local\Android\sdk\
start AVD Manager and in the second tab(Device Definitions) click on the button "createAVD".
All you need to do is install the platform for the desired emulator example for android 11
sdkmanager --install "platforms;android-30"
after you do this your emulator will start working just fine.
I had the same issue which after setting following path variables got vanished
Note AVD Home path is different from other three.
Check if the system image used by your AVD has been downloaded under $ANDROID_SDK_ROOT/system-images/
Just ran into that issue today and managed to solve it.
Emulator: [140735565005632]:ERROR:android/android-emu/android/qt/qt_setup.cpp:28:Qt library not found at /Users/your_user_name/Library/Android/sdk/emulator/lib64/qt/lib
15:08 Emulator: Could not launch '/Users/your_user_name/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-x86_64': No such file or directory
The solution was pretty simple. Just install Android emulator through Android Studio => tools => Android => SDK manager => SDK tools => select Android Emulator => Apply
I'm using a MacBook Pro on macOS High Sierra, and I believe your machine has nothing to do with this issue. The emulator is not obviously installed when running the Android Studio installation manager for the first time, at least for me, with Android Studio 3.0.1
Also make sure you have your paths defined in your .bashrc or .zshrc like this:
export ANDROID_HOME=/Users/your_user_name/Library/Android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
NativeScript
For anyone having trouble launching the android emulator via NativeScript, it's likely env vars ANDROID_HOME and ANDROID_SDK_ROOT have been overridden.
How I managed to create a problem for myself was by installing Android Studio to generate a different emulator. I did this after I had already installed the android sdk via home brew.
So if during the NativeScript installation, you selected to install android sdk via HomeBrew, NativeScript will set the above as follows:
ANDROID_HOME=/usr/local/share/android-sdk
ANDROID_SDK_ROOT=/usr/local/share/android-sdk
Subsequently installing Android Studio will override these values as:
ANDROID_HOME=/Users/[User]/Library/Android/sdk
ANDROID_SDK_ROOT=/Users/[User]/Library/Android/sdk
So naturally there is a conflict with Android studio and the NativeScript/Brew installation of the android sdk. Removing one or the other and/or verifying that the env variable contain the correct path should get your emulator to launch.
Delete early created devices.
Close Android studio.
Open: Control panel -> System & security -> System -> Advanced system settings ->
Environment variables.
Create New variable "ANDROID_SDK_HOME" and set
new path(in my case it was F:\Coding2019\Android\AVDdevices). Push 'ok'.
Open Android Studio.
Create new device. After creating in drop-down menu click "View Details" to see new path of new AVD.
中国的小伙伴注意!原因是avd目录不能包含中文
I tried all these method above, and I still get the error, and I wonder if it's because my avd directory contains chinese charactor. so I change The default avd directory by the following steps, and it worked.
1. create a folder whose path doesn't contain non-ascii character
2. copy or cut the default avd folder $HOME/.android below the folder you just created
3. add PATH ADNDROID_SDK_HOME, and the Android studio will find avd below $ADNDROID_SDK_HOME/.android/avd
finally it worked out! :>
In Windows 10 (without Android Studio) I solved the "PANIC: Broken AVD system path" by transferring '.android' folder from its default place in "C:\Users\Леон" into SDK folder. And change Environment as
ANDROID_SDK_ROOT=D:\Android\SDK
ANDROID_AVD_HOME=%ANDROID_SDK_ROOT%\.android\avd
ANDROID_EMULATOR_HOME=%ANDROID_SDK_ROOT%\.android
I suppose the problem might be either in non-ASCII symbols in my USER's path or they need to be "all together"
After quite some time trying other Googled "solutions", the only thing that worked for me, after setting the ANDROID_SDK_ROOT environment variable on Windows, and also adding and removing ANDROID_HOME and ANDROID_SDK_HOME variables, was Xerox23's answer - editing the AVD's config.ini to hardcode the value of ANDROID_SDK_ROOT into the image.sysdir.1 property.
This was using Android Studio 3.0.1 and emulator 26.1.4, launching the virtual device from the AVD Manager from within Android Studio.
For windows machine: After trying alot of set path, remove path and etc.
What finally work is to located the folder C:\Users\johndoe\.android and delete it. after that you can lunch your Android Studio, it will ask you to download and install a new AVD and it will override and create a fresh new folder and files. This solve the problem.
To solve this problem I had to install the package with the missing system image using SDK Manager.exe (in "C:\Program Files (x86)\Android\android-sdk"). I had noticed that the system image I needed ("android-23") was missing in "C:\Program Files (x86)\Android\android-sdk\system-images".
After running SDK Manager.exe and installing the appropriate packages I could run the emulator in Android Studio.
Here's the solution that worked for me:
https://www.embarcadero.com/starthere/xe5/mobdevsetup/android/en/creating_an_android_emulator.html
Follow below steps this should solve your problem
1.
export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/bin
2.
Go to android studio preferences => Build, Execution, Deployment => Build Tools => Gradle => Android studio => Enable embedded Maven Repository should be selected.
3.
Go to android studio preferences => Appearance & Behavior => System Settings => Android SDK => Go to SDK Tools and select Android Emulator
The errors actually vary. It's helpful to run ./emulator with -verbose option, as it will show the actual errors.
I solved this problem by removing the file /usr/local/share/android-sdk,
because this file was created when I tried with homebrew .
export ANDROID_HOME=/Users/<username>/Library/Android/sdk
export ANDROID_SDK_ROOT=/Users/<username>/Library/Android/sdk
export ANDROID_AVD_HOME=/Users/<username>/.android/avd
that is enough ....
Open your android studio then focus on the toolbar.
Goto tools > SDK manager then
Appearance & Behavior > Systems Settings > Android SDK
Now in the tab copy the Android SDK Location from here
Android SDK Location
then goto your environment variables and then set the path along with these variables
ANDROID_HOME
ANDROID_SDK_ROOT
Environment Variables
Related
I've followed step by step the official Getting Started. I started from a clean linux install and installed everything required as per the "Building Projects with Native Code" tab. I have also read the troubleshooting section. I've already created the project using the terminal.
This is the error when I run react-native run-android:
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
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.
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/android-setup.html
It does not find JAVA_HOME because the latest versions of Android Studio don't require Java to be installed in the system. Instead an internal JRE is used.
Duplicate disclaimer: I've already read this question. This is not what I want. I know how to set the Java home. I just want to run the react project WITHOUT having to install a separate Java.
Questions:
How could I find the internal Java inside the Android Studio folder so that I could point JAVA_HOME to it?
If not possible, could I open and run the project inside the android folder with Android Studio? How would I refresh this project after modifying the React JavaScript code in the parent folder?
Windows 10:
Android Studio -> File -> Other Settings -> Default Project Structure... -> JDK location:
copy string is shown, such as:
C:\Program Files\Android\Android Studio\jre
In the file locator directory window, right-click on "This PC" ->
Properties -> Advanced System Settings -> Environment Variables... -> System Variables
click on the New... button under System Variables, then type and paste respectively:
.......Variable name: JAVA_HOME
.......Variable value: C:\Program Files\Android\Android Studio\jre
and hit the OK buttons to close out.
Some installations may also require JRE_HOME to be set in the same way.
To check, open a NEW black console window, then type echo %JAVA_HOME%. You should get back the full path you typed into the system variable. Windows 10 supports spaces in the filename paths for system variables very well and does not need ~tilde eliding.
I'll answer my own questions and sponfeed my fellow linux users:
1- To point JAVA_HOME to the JRE included with Android Studio first locate the Android Studio installation folder, then find the /jre directory. That directory's full path is what you need to set JAVA_PATH to (thanks to #TentenPonce for his answer).
On linux, you can set JAVA_HOME by adding this line to your .bashrc or .bash_profile files:
export JAVA_HOME=<Your Android Studio path here>/jre
This file (one or the other) is the same as the one you added ANDROID_HOME to if you were following the React Native Getting Started for Linux. Both are hidden by default and can be found in your home directory. After adding the line you need to reload the terminal so that it can pick up the new environment variable. So type:
source $HOME/.bash_profile
or
source $HOME/.bashrc
and now you can run react-native run-android in that same terminal. Another option is to restart the OS. Other terminals might work differently.
NOTE: for the project to actually run, you need to start an Android emulator in advance, or have a real device connected. The easiest way is to open an already existing Android Studio project and launch the emulator from there, then close Android Studio.
2- Since what react-native run-android appears to do is just this:
cd android && ./gradlew installDebug
You can actually open the nested android project with Android Studio and run it manually. JS changes can be reloaded if you enable live reload in the emulator. Type CTRL + M (CMD + M on MacOS) and select the "Enable live reload" option in the menu that appears (Kudos to #BKO for his answer)
I think the right way to find the internal Java used by the Android Studio is to
Open Android Studio
Go to File->Other Settings->Default Project Structure/JDK Location:
and copy what ever string is specified there
This will not require memorising the folder or searching for java and also these steps wil take of any future changes to the java location by the Android Studio team changes I suppose
I'm using Ubuntu 20 on my machine, I have got the same problem the thing that worked for me was:
sudo apt-get install default-jre
you can verify that if the installation was successful or not by:
java --version
you are gonna see something like this in your terminal
openjdk 11.0.12 2021-07-20
OpenJDK Runtime Environment (build 11.0.12+7-Ubuntu-0ubuntu3)
OpenJDK 64-Bit Server VM (build 11.0.12+7-Ubuntu-0ubuntu3, mixed mode, sharing)
It is located on the Android Studio folder itself, on where you installed it.
Please add the JAVA_HOME in the System variable no in the user variable
Create the Variable name as JAVA_HOME
Please use these format in the value box --> C:\Program Files\Java\jdk(version) what you have or downloaded.
I fixed this issue by installing jre, I have jdk already installed but jre was not installed.
For those still not able to set JAVA_HOME from Android Studio installation, for me the path was actually not in C:\...\Android Studio\jre
but rather in the ...\Android Studio\jre\jre.
Don't ask me why though.
Environment variables jre location snippet
For ubuntu 16.0+
You can find the jre folder in android studio on this path /snap/android-studio/current/android-studio/jre
add the following line in your .bashrc or .bash_profile
export JAVA_HOME=/snap/android-studio/current/android-studio/jre
type
sudo nano $HOME/.bashrc
or
sudo nano $HOME/.bash_profile
after this execute the following line to in your terminal where you are executing the npx react-native run-android to reload the terminal with the new changes
source $HOME/.bashrc
or
source $HOME/.bash_profile
All I did is go to my project directory from the cmd (command prompt) I typed java -version.it told me what version it was looking for. so I Installed that version and I changed the path to were the jdk of that version was located .
apparently the system variables were not in sync with the user
variables
run as admin on command prompt and set the variable
i also saw some tips to close the node window and the vscode terminal for
the variable to take effect
tip from this site
https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html
setx -m JAVA_HOME "C:\Progra~1\Java\jdk1.8.0_XX"
and then
echo %JAVA_HOME%
For fish users:
Open ~/.config/fish/config.fish;
Include line set JAVA_HOME /home/ronald/Documents/android-studio/jre and set PATH $PATH $JAVA_HOME;
Re-open fish terminal.
Welcome :)
After adding the environmental variable , please restart the editor. It may save your ton of time.
Make sure you have java installed
your path is wrong
do this:
export | grep JAVA
THE RESULT: what java home is set to
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
follow the path to see if the directories are correct
i did this in my terminal:
open /Library
then i went to /Java/JavaVirturalMachines
turns out I had the wrong "jdk1.8.0_202.jdk" folder, there was another number...
4. you can use this command to set java_home
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
I ran this in the command prompt(have windows 7 os):
JAVA_HOME=C:\Program Files\Android\Android Studio\jre
where what its = to is the path to that jre folder, so anyone's can be different.
what I did to solve this on windows was to go to the environment variables and set the variable name to JAVA_HOME and then set the variable value to C:\Program Files\OpenJDK\openjdk-8u312-b07
then I set the path to C:\Program Files\OpenJDK\openjdk-8u312-b07\bin
From Android Studio, go to File, Settings, "Build, Execution, Deployment", Build Tools, Gradle. You should see the path to your JDK there, as visible in the screenshot (tested on Android Studio version 2020.3.1). Set an environment variable called JAVA_HOME containing that path (just google "set an environment variable" and followed by your Operating System name).
for those who are new to react native development
please set JAVA_HOME like this
instead of
C:\Program Files\Java\jdk1.8.0_301\bin
just remove "\bin" from path
C:\Program Files\Java\jdk1.8.0_301 after removing \bin
Guys after fight a lot to find the solution, including pass for many of that articles. I just realized that when you extract the Android SDK it doesn't come inside the folder cmdline-tools/latest and doesn't matter the place that I put the folder, opt/Androd_SDK, $HOME/Android_SDK the sequence of the error were the same. Until I got this error running:
➜ bin ./sdkmanager -version
Error: Could not determine SDK root.
Error: Either specify it explicitly with --sdk_root= or move this package into its expected location: /cmdline-tools/latest/
So, basic the solution was add the content of the SDK zip inside of the folders cmdline-tools/latest.
Once you do this, SDK and all the commands will work normally. Just don't forget to finish the configuration, like create the environment of the Android SDK, JAVA and so on.
An awesome article is that one:
https://medium.com/#khairold/setting-up-react-native-on-linux-without-android-studio-a65f3e011bbb
;)
if someone still facing similar issue and looking for an answer for the same? I would like to share the solution which worked for me. And by the way I haven't installed JAVA JDK/SDK in order to resolve the issue.
I am using Visual Studio code to develop react-native apps (using nox player for android app testing), I ran into the similar issue:
Issue:
$
› Building 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.
C:\Users...\android\gradlew.bat exited with non-zero code: 1
Resolution: In package.json file I have changed "main": "index.js" to "main": "node_modules/expo/AppEntry.js" it worked for me.
It would be great if this solution helps anyone, let me know for any additional information.
Make sure you have installed the following:
Java
JDK
JRE
If you use Ubuntu, maybe its helpful this tutorial. You have solution for how to solve error ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH..
There are many solutions found for Windows or Mac OS on internet to resolve this error. I'm using Ubuntu 22.10 kinetic
Solution:
Go to your Android Studio folder, find folder named jbr, copy all content folder, and if you don't have, create a folder named jre and copy in jre folder, all contents from jbr folder. Case close. Error solved.
java is not set
Video
I have installed Android Studio on my MacBook Air (OS Version 10.11 El Capitan) and have successfully written a small "hello, world" app and installed on device (Nexus 7) and ran on AVD. All I want to do now is be able to build the app and install it on device from the command line as opposed to Android Studio. I'm following the directions here:
http://developer.android.com/training/basics/firstapp/running-app.html
and the relevant line is:
Make sure the Android SDK platform-tools/ directory is included in your PATH environment variable, then execute:
The problem is I can't find the Android SDK on my machine! I assume it's there because otherwise the program wouldn't compile and run through Android Studio? Perhaps that's a bad assumption? I'm new to Macs (I'm used to Windows) so I don't know the best way to search for the Android SDK. So my questions:
How do I find Android SDK on my machine? Or prove to myself it's not there?
If it's not there how do I install it?
How do I change PATH to include Android SDK?
1. How to find it
Open Android studio, go to Android Studio > Preferences
Search for sdk
Something similar to this (this is a Windows box as you can see) will show
You can see the location there – most of the time it is:
/Users/<name>/Library/Android/sdk
2. How to install it, if not there
Go to Android standalone SDK download page
Download the zip file for macOS
Extract it to a directory
3. How to add it to the path
Open your Terminal edit your ~/.bash_profile file in nano by typing:
nano ~/.bash_profile
If you use Zsh, edit ~/.zshrc instead.
Go to the end of the file and add the directory path to your $PATH:
export PATH="${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/platform-tools:${PATH}"
Save it by pressing Ctrl+X
Restart the Terminal
To see if it is working or not, type in the name of any file or binary which are inside the directories that you've added (e.g. adb) and verify it is opened/executed
If you don't want to open Android Studio just to modify your path...
They live here with a default installation:
${HOME}/Library/Android/sdk/tools
${HOME}/Library/Android/sdk/platform-tools
Here's what you want to add to your .bashwhatever
export PATH="${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/platform-tools:${PATH}"
Find the Android SDK location
Android Studio
> Preferences
> Appearance & Behaviour
> System Settings
> Android SDK
> Android SDK Location
Create a .bash_profile file for your environment variables
Open the Terminal app
Go to your home directory via cd ~
Create the file with touch .bash_profile
Add the PATH variable to your .bash_profile
Open the file via open .bash_profile
Add export PATH=$PATH: [your SDK location] /platform-tools to the file and hit ⌘s to save it. By default it's:
export PATH=$PATH:/Users/yourUserName/Library/Android/sdk/platform-tools
Go back to your Terminal App and load the variable with source ~/.bash_profile
How do I find Android SDK on my machine? Or prove to myself it's not there?
When you install Android studio, it allows you to choose if you want to download SDK or not
If it's not there how do I install it?
you can get SDK from here http://developer.android.com/sdk/index.html
How do I change PATH to include Android SDK?
in Android Studio click in File >> Settings
If Android Studio shows you the path /Users/<name>/Library/Android/sdk
but you can not find it in your folder, just right-click and select "Show View Option". There you will be able to select "Show Library Folder"; select it and you can access the SDK.
The default path of Android SDK is /Users/<username>/Library/Android/sdk, you can refer to this post.
add this to your .bash_profile to add the environment variable
export PATH="/Users/<username>/Library/Android/sdk/tools:/Users/<username>/Library/Android/sdk/build-tools:${PATH}"
Then save the file.
load it
source ./.bash_profile
AndroidStudioFrontScreenI simply double clicked the Android dmg install file that I saved on the hard drive and when the initial screen came up I dragged the icon for Android Studio into the Applications folder, now I know where it is!!! Also when you run it, be sure to right click the Android Studio while on the Dock and select "Options" -> "Keep on Dock".
Everything else works.
Dr. Roger Webster
For Visual Studio for Mac users (e.g. who installed Android SDK together with VS):
open Visual Studio for Mac
select from menu: Tools -> SDK Manager -> Select 3rd tab: 'Localizations' in dialog
You can find JDK, Android NDK and Android SDK localizations there (if installed and selected). If no Android SDK path found, you may try to find it using Android Studio (if it is installed)
In my case, I had to create local.properties file with sdk.dir=PATH_TO_ANDROID_SDK in my machine. It seems that, it's regarding the android sdk path setup. Hence, it could also be set in ANDROID_HOME env. variable too.
I found it here:
/Users//Library/Android/sdk
and Platform-tools is available as well
I've downloaded and installed the Genymotion emulator plugin via the plugin wizard in Android Studio. I'm running Android Studio on a Windows machine.
I'm getting a warning saying that I must provide a path to Genymotion folder:
Where is this folder located? I can not seem to find it in my Android Studio installation folder.
For windows, the default path is C:\Program Files\Genymobile\Genymotion
On a Mac, you will find it here: /Applications/Genymotion.app
You have to enter it inside the Android Studio settings, under Genymotion section.
make sure you have installed genymotion and virtual box then provide the link to genymotion location in windows by default is C:/program files/genymobile/genymotion
Not sure if anyone had the same problem but I received this same warning from Android Studio when clicking on the Genymotion Plugin warning me that
"You must specify a path to genymotion folder to use this feature"
The path was correct according to previous answers for a Mac but the problem was simply that the Genymotion plugin just needed to be updated. I went to Android Studio > Preferences > Plugins > Genymotion and selected update (This is on a mac) and the problem went away after I updated the plugin and restarted Android Studio. Hope this helps someone else with the same problem.
What to do:
Open Genymotion itself (the round & pink icon on your desktop).
Choose the "Settings" option from the upper menu.
Choose the option "ADB" from the upper menu.
Select "Use Android custon SDK tools". Put the following path inside "Android SDK": C:\Program Files\Genymobile\Genymotion
Why does it happen? you're getting the notice "You must specify a path to Genymotion folder to use this feature" because there's a bug in Genymotion working on Windows that misleads the Genymotion engine while trying to use the Android SDK.
Additional links:
Can't find Genymotion.app
On a Ubuntu, you will find it here: /home/user/opt/genymobile/genymotion
For Linux system :
though your genymotion is installed in "/usr/bin" folder its actually points to opt directory in root.
Use following path in android studio for genymotion :
/opt/genymotion
If you are getting this error after clicking installed plugin then, its asking the path of your installed Genymotion. So please provide path where your Genymotion is installed.
In my case it was C:\Program Files\Genymobile\Genymotion
In Linux, the way to solve the issue is the re-run the command
sudo ./genymotion-x.x.x-linux_x64.bin
in the directory where your bin file is located. For instance, suppose that I download the Genymotion .bin file to install Genymotion, and it's in the Downloads folder. I can move it to my home folder and run the following commands to install it.
chmod +x genymotion-x.x.x-linux_x64.bin
sudo ./genymotion-x.x.x-linux_x64.bin
After running those commands, you may run into an issue where the genymotion folder needed to specify the path does not get created. If you try pressing CTRL + h in the directory where your .bin is located, you will find a hidden folder called .Genymobile. The Genymotion folder will be inside of that folder. Even if you were to specify the path to that folder as /home/<user>/.Genymobile/Genymotion, you would still get the error. If you re-run the command sudo ./genymotion-x.x.x-linux_x64.bin where your .bin file is located, it will create the genymotion folder, and you can specify the path as /home/<user>/genymotion if the .bin file is located in your home directory. Once you specify the path, you can press ok, and it should work.
In case it helps, when I needed to add the Genymotion install dir to my $PATH environment variable on Mac OS X, I had to use the following path:
/Applications/Genymotion.app/Contents/MacOS
Simply write
C:\Program Files\Genymobile\Genymotion
It is the default path for the GennyMotion unless you have installed it somewhere else.
To install Genymotion plugin for Android Studio:
In Android Studio, go to File/Settings (for Windows and Linux) or to Android Studio/Preferences (for Mac OS X)
Select Plugins and click Browse Repositories.
Right-click on Genymotion and click Download and install. To see Genymotion plugin icon, display the toolbar by clicking View > Toolbar.
To use this plugin, Genymotion must be installed on your system.
Or download and install manually the plugin genymotion-idea-plugin.jar (not recommended)
You have to give installed path of genymotion.
More Details You can Visit Official Genymotion Website.
I am trying to add android as a cordova platform so that I can build apps with phonegap. When I tried to add android thus:
$ cordova platform add android
I received this error message:
[Error: The command android failed. Make sure you have the latest
Android SDK installed, and the android command (inside the tools/
folder) added to your path. Output: /bin/sh: android: command not
found ]
I do have the latest Android SDK installed, so I suppose I need to add android to my path. I've googled on how to do that, and searched this forum, but I have little knowledge of command line use and I don't understand the answers.
If someone could provide very simple steps to add android to my path, I would be most grateful.
There's step-by-step instructions on the PhoneGap Doc's. Check it out here, and then go to Step 3B. I linked to the 2.8 version of PhoneGap since from a quick look it doesn't seem to explain how to set up PATH on the 3.0 version docs.
I just figured this out. You need to use the path where your android tools are actually installed. Mine happen to be in the default location (and I'm using x64) so, /Applications/adtbundle name/
Just see for yourself!
I was running into a rather silly problem here. The path that I cut and pasted had the adt-bundle listed as "adt-bundle" (as one might expect :)) but I never changed the name of the directory as it was downloaded, which was "adt-bundle-mac-x86_64-20131030."
Additionally, the path ($PATH) that I cut and pasted into my .bash_profile began with "/Development" when it should have begun with "~/Development" since the Development directory was in my home directory.
I don't know if anyone else might find this info useful, but it was a relief to me when I realized that I just needed to correct the paths I'd specified in .bash_profile.
Its very easy. Just Download the android SDK, later set the path android sdk having folder tools and platforms tools in the system variables. Now later the set the path of ANDROID_HOME in the user variable. That's it. Now you can add, run , build your android platform.
On MAC - I got this problem after installing Android Studio (it was working before).
I had to do:
touch ~/.bash_profile; open ~/.bash_profile
and then add the line
export PATH=$PATH:/Users/<USR>/Library/Android/sdk/tools
and restart terminal.
If you used Eclipse to install and manage Android SDK then do following:
Open Window->Android SDK Manager in Eclipse and in new window you will be able to see SDK Path on the top
Now you should include this path as ANDROID_HOME system variable and export /tools and /build-tools it to system PATH variable
On OS X you can include system variables like following:
In Terminal run nano ~/.bash_profile (because probably the .bash profile is not create yet, it will we created in root folder of your User)
In my case SDK path was '/Users/markusila/android-sdks'
Insert following code, but using your SDK path, into the editor opened
export ANDROID_HOME=/Users/YOUR_USER_NAME/android-sdks
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Now simply run . ~/.bash_profile and changes will be included.
In addition to the answers above, don't forget to update the file based in your favorite shell, for example:
ZSH:
1. vi ~/.zshrc
2. Considering that my Android SDK is in "/Users/wils/Library/Android/sdk/" and using vi as editor:
export PATH="/Users/wils/Library/Android/sdk/platform-tools:/Users/wils/Library/Android/sdk/tools:$PATH"
3. Save
4. source ~/.zshrc
BASH:
1. vi ~/.bash_profile
2. Considering that my Android SDK is in "/Users/wils/Library/Android/sdk/" and using vi as editor:
export PATH="/Users/wils/Library/Android/sdk/platform-tools:/Users/wils/Library/Android/sdk/tools:$PATH"
3. Save
4. source ~/.bash_profile
I hope it help somebody else.
Piece \o/
I downloaded Android Studio and attempted to launch the program.
This is running on Windows 7 64-bit with Java 1.7. During the installation, my Java 1.7 is detected, and the rest of the installation goes through just fine. However, when attempting to launch the application from the desktop icon, nothing happens. Looking at the task manager, a new process from the CMD is loaded. This is because it's attempting to run the batch file studio.bat.
When I execute via CMD, I get the following error:
ERROR: cannot start Android Studio. No JDK found. Please validate
either ANDROID_STUDIO_JDK or JDK_HOME or JAVA_HOME points to valid
JDK installation. ECHO is off. Press any key to continue . . .
I've attempted to open the idea properties file to see if there was something I could configure for this ANDROID_STUDIO_JDK or something like that. However, I found nothing. I hope some of you can let me know if you were able to install this or if you are having problems as well.
Adding a system variable JDK_HOME with value c:\Program Files\Java\jdk1.7.0_21\ worked for me. The latest Java release can be downloaded here.
Additionally, make sure the variable JAVA_HOME is also set with the above location.
OK, I figured out how fix this nasty bug.
Before you start
Go to your Android Studio installation folder and locate the bin folder. Inside the bin folder, you will find studio.bat. Execute the file, and it'll show the error. If it is about the Java path then follow the tip 1.
Tip 1
When you set the path JAVA_HOME, etc., make sure not to include bin at the end of the path. This solved the issue for me.
JAVA_HOME => C:\Program Files\Java\jdk1.7.0_21
path => C:\Program Files\Java\jdk1.7.0_21\bin
It works fine with JDK 1.7 (I tried with 32 bit).
If you do so, you can see the initial screen as below.
Tip 2
Are you getting the below error message?
Your Android SDK is out of date or is missing templates. Please ensure
you are using SDK version 22 or later.
This error probably occurs, because you have reference to your older SDK (that you downloaded with Eclipse) in your path variable. Go to Environment variables and remove any reference to the old SDK folder and point it to new SDK folder that is found inside the Android Studio installation folder.
Save and restart Studio, things should work as expected now.
Tip 3
If you hate messing around with the path variable as given above by removing old references, simply follow the following steps to refer to new SDK path that comes with Studio.
*Project Defaults* -> *Project Structure* -> Click "New" -> Select "Android SDK" -> Select the SDK folder inside the studio installation.
With the last update of Android Studio, I have two versions of the IDE's launcher
One is called studio.exe and the other studio64.exe they are both on:
C:\Users\myUserName\AppData\Local\Android\android-studio\bin
You have to launch the one that matches your Java version 64 or 32 bit
I had the same issue. I got resolved setting up correctly the environment variables in windows, for instance:
JAVA_HOME -> C:\Program Files\Java\jdk1.6.0_45
path -> C:\Program Files\Java\jdk1.6.0_45\bin
I've tried so many of the answers here but none of them works, so I decided to mix some of the answers here and I am successful!
Step 1: Go to the system properties by right-clicking on My Computer or by pressing windows button on typing This PC and right clicking on it and selecting Properties.
Step 2: Click the advanced system settings or Environment Variables
Step 3: Take note that there are 2 different variable. What you need to create is system variables not user variables, when you clicked new type the following
Variable name: JAVA_HOME
Variable value: C:\Program Files\Java\jdk1.8.0_25\ (Note: Please check if the path is right, sometimes it is C:\Program Files (x86)\Java\jdk1.8.0_25)
Step 4: Run the android studio, no need to restart.
Note:
*C:\Program Files\Java\jdk1.8.0_25\ depends entirely on the installation path of your JDK not JRE so don't be confused if you see something like the picture below. Just enter the location of your jdk, in my case it is C:\Program Files\Java\jdk1.8.0_25\.
*Do not include the bin folder when you enter the Variable value.
Edit: For Windows 8 and 10 Users: Try to run C:\Program Files\Android\Android Studio\bin\studio.exe instead of C:\Program Files\Android\Android Studio\binstudio64.exe
I had the same issue. I am having 64-bit windows 8. I downloaded the android studio which worked on a 32-bit machine but not on my 64-bit.
The solution for me was pretty simple. I navigated to
C:\Program Files (x86)\Android\android-studio\bin
there I saw 2 exe files studio.exe and studio64.exe. Normally my start menu was pointing to studio64.exe which always kept on giving me "The environmental variable JDK_HOME does not point to valid JVM". So then I clicked studio.exe and it worked :)
I hope this may help someone facing the same problem as me
The path for the latest JDK. It worked very well.
If you are getting message "Your Android SDK is out of date…" — click "Configure" —> "Project Defaults" —> "Project Structure", pick "SDKs" —> "Android SDK" and in a "Build Target" choose "Android 4.2.2". Click "OK". Now it should work fine.
I got the problem that the installation stopped by the "$(^name) has stopped working" error. I have installed the Java SE Development kit already, and also set both SDK_HOME and JAVA_HOME that point to "C:\Program Files\Java\jdk1.7.0_21"
My laptop installed with Windows 7 64 bits
So I tried to install the 32-bit version of the Java SE Development kit, and set my JAVA_HOME to "C:\Program Files (x86)\Java\jdk1.7.0_21", restart and the installation worked OK.
This problem has been fixed in Android Studio v0.1.1, so just update Android Studio and it should work.
Sometimes you can resolve this type of issue by setting environment variables so the process looks for the JDK in the right spot.
Another approach is to figure out where the process is looking, then put your JDK there.
I've had lots of success using Process Monitor from Sysinternals:
Start -> Run -> procmon
Go to the Filter menu, then select Filter...
Set Event Class is File System then Include
Add, then OK
This will filter down to all the file system operations taking place on your machine.
You could try filtering based on the result of the File System operation:
Right click on the Result column, then Exclude 'SUCCESS'
You can also quite easily filter based on the process name, either from the Filter... menu option or by right clicking on the Process Name column and selecting Include 'process.exe'.
Once you find the file system operation that's failing, the Path column will tell you where to put your JDK.
I've found this to be very empowering. Especially compared to the frustrating process of changing environment variables by trial and error.
My issue was caused because I have an & character in my Windows user name, so when installed in the default path I was getting the following error after running bin/studio.bat
|
v notice broken path
The system cannot find the file C:\Users\Daniel \studio64.exe.vmoptions.
Exception in thread "main" java.lang.NoClassDefFoundError: com/intellij/idea/Main
Caused by: java.lang.ClassNotFoundException: com.intellij.idea.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: com.intellij.idea.Main. Program will exit.
So I uninstalled and reinstalled it to program files and it launches fine now.
I couldn't get this to work no matter which environment variables I set. So I simply put a copy of the JDK into my Android Studio installation folder.
Copy the contents of the JDK installation (for example, C:\Program Files (x86)\Java\jdk1.7.0_21)
Paste them into the installation directory of the Android Studio (for example, C:\Program Files (x86)\Android\android-studio)
I somewhat assumed that the issue was caused by having the x64 version of the JDK installed. But what was especially confusing was the fact that I could start Android Studio just fine when I started the studio.bat as an Administrator (even though the environment variables were set for my personal user account).
studio.bat will look for several valid options when determining which JDK to use.
:: Locate a JDK installation directory which will be used to run the IDE.
:: Try (in order): ANDROID_STUDIO_JDK, ..\jre, JDK_HOME, JAVA_HOME.
As explained above, I picked the ..\jre option.
Today I found another situation when this problem occures - when you have several JDK, defined in JAVA_PATH. I have:
JAVA_HOME = C:\JAVA\JDK\jdk1.6.0_38;C:\JAVA\JDK\jdk1.7.0_10
So I received this problem with Android Studio setup
But when I've removed one of JDK - problem has been solved:
JAVA_HOME = C:\JAVA\JDK\jdk1.7.0_10
Installation wisard found my jdk and i had a nice night to study studio.
But unfortunatelly even installed studio doesn't work with several jdk.
Does anybody know how to fix it?
I hope I've helped someone
Add JAVA_HOME and JDK_HOME system environment variables.
Right-click
android studio (the 64 version if that's your OS and JDK) and go to
compatibility tab and set "Run as administrator" to true.
Run android studio and high-five me virtually when it works.
If that fails, try "where java" in cmd.exe. If it lists c:\system32\java.exe first, then rename the file and try again.
Windows 64 bit, JDK 64 bit (Solution that worked for me)
Tried all the above solutions, and None of them worked, I have been trying to solve it for the past few days and now I did it successfully. For me the problem was when I first installed Android Studio my JDK version was 1.7, then after installing I updated the JDK to 1.8, then I removed the old JDK folder and everything was messed up, even uninstalling and reinstalling android studio randomly didn't solve the issue.
Below is the solution that worked for me
Uninstall Android Studio.
clean temp files and android studio C:\Users\Username.AndroidStudio1.5
Uninstall JDK.
Now without JDK try to install Android Studio and now it will show the message that it can't find any JDK. Stop installation
Install JDK 1.7 or 1.8 (Set JAVA_HOME, JDK_HOME, path Environment variables as explained by everybody above)
Install Android Studio.
Done. Enjoy and happy coding.
MAKE SURE YOU RESTART ANDROID STUDIO
Even though I should know better and swear I did, make sure you restart studio after making these changes as it clearly does not check them on every build (which to me makes sense that system/user variables should only be read once on startup)
Anyway, yea... Make sure you restart after you make these changes.
Path = to the bin folder in the jdk folder (path already exists)
JAVA_HOME = to the jdk folder
Install the latest JDK in your system from JDK 7 and JRE 7 Installation Guide.
JAVA_HOME -> C:\Program Files\Java\jdk1.7.0_4
path -> C:\Program Files\Java\jdk1.7.0_4\bin
If setting the JAVA_HOME variable doesn't work for you, set:
STUDIO_JDK=C:\Progra~1\Java\jdk1.8.0_172
Where the path points to your JDK installation
This is the only thing which works for me in Windows 32bit with Android 10 and up.
In my experience, I was unable (even after adding JDK_HOME) to launch Studio via either the shortcut or studio.exe itself. I had to first run bin/studio.bat (mentioned in the original question).
After the first successful launch, I'm able to start it with the shortcut.
If you have a 64 bit windows OS, pointing the JAVA_HOME system variable to
C:\Program Files (x86)\Java\jdk1.7.0_21
Will work when
C:\Program Files\Java\jdk1.7.0_21
fails to work.
You need 1.7 JDK installed on your system. Add a system variable with:
name: ANDROID_STUDIO_JDK
path: your JDK path (for example, C:\Program Files\Java\jdk1.7.0_21)
See more at FIX: Android Studio - Installation Issues on Windows 7 | ERROR: cannot start Android Studio. No JDK found.
TRY TO INSTALL 32BIT JDK
if you have jdk installed and had set up the System Varibles such as JAVA_HOME or JDK_HOME
and tried click back and then next ,you might have installed the 64bit JDK,just download the 32bit jdk and install it.
I downloaded the latest jdk version
JAVA_HOME to C:\Program Files\Java\jdk1.8.0_11\bin
Set the PATH to C:\Program Files\Java\jdk1.8.0_11\bin
I restarted the STUDIO and it worked.
On Windows 10, restarting the installer and running as admin worked for me.
To complete this stack of possible solutions: For me the problem was, that I did not execute the Android-Studio-Setup as administrator. Running it as administrator then made me able to install Android-Studio.
For me, the problem was that I had changed the GC vm arg to -XX:+UseParallelGC in the C:\Users\<username>\.AndroidStudio2.1\studio64.exe.vmoptions file. That's what I use in Eclipse and I was trying various things to get AndroidStudio half way as efficent as Eclipse. I restored the GC to -XX:+UseConcMarkSweepGC.
The answer to the original question is that, might be you are opening android studio from 32 bit shortcut icon of android studio, try to open from icon "studio64" located under .../bin/ where android studio setup is install.
In case you had it running but Now it doesn't Launch.
I deleted the C:\Users\<NAME>\.AndroidStudio<version>\ folder and it worked.