I'm trying to install PhoneGap and I'm getting the following error:
Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
Error (screenshot)
What do I do to ensure Android is set up correctly for use with Cordova?
For Windows:
set ANDROID_HOME=C:\ *installation location* \android-sdk
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
Taken from this installation guide.
For Mac OS X:
export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
I have MAC OS X Yosemite, Android Studio 1.0.1, JDK 1.8, and Cordova 4.1.2
When I tried to add the android project:
cordova platforms add android
I received the message:
ANDROID_HOME is not set and "android" command not in your PATH
Based in cforcloud's answer...
'Error: the command "android" failed' using cordova
and
http://developer.android.com/sdk/installing/index.html?pkg=studio
I used the following:
export ANDROID_HOME="/Users/<user_name>/Library/Android/sdk"
export ANDROID_TOOLS="/Users/<user_name>/Library/Android/sdk/tools/"
export ANDROID_PLATFORM_TOOLS="/Users/<user_name>/Library/Android/sdk/platform-tools/"
PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS
echo $PATH
When I tried to create the android project, I received this message:
Creating android project...
/Users/lg/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:126
throw e;
^
Error: Please install Android target "android-19".
I ran Android SDK Manager, and installed Android 4.4.2 (API 19) (everything but Glass Development Kit Preview). It worked for me.
===
This is the content of my .bash_profile file.
export PATH=$PATH:/usr/local/bin
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
launchctl setenv STUDIO_JDK /library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
export ANDROID_HOME="/Users/<UserName>/Library/Android/sdk"
export ANDROID_TOOLS="/Users/<UserName>/Library/Android/sdk/tools"
export ANDROID_PLATFORM_TOOLS="/Users/<UserName>/Library/Android/sdk/platform-tools"
PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS
To edit .bash_profile using Terminal, I use nano. It is easy to understand.
cd
nano .bash_profile
I hope it helps.
for windows:
Right click on My computer -> properties -> Advanced system setting -> Environment Variables
Edit Path on system variables to ;\yourSdkHome\tools;\yourSdkHome\platform-tools.
Then Close your cmd prompt and reopen.
On Linux, add this to the end of your .bashrc, .profile or appropriate file for your shell:
export ANDROID_HOME=/home/youruser/whatever/adt-bundle-linux-x86_64-20140702/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platforms-tools
Please notice that these environment variables will be available for newly created shells, not the already open.
Using Android Studio on Windows the system variables settings have changed a little.
You still have to add a system variable ANDROID_HOME, but pointing to the directory containing the android SDK usually installed in C:\Users\YOUR_USERNAME\AppData\Local\Android\android-studio\sdk.
You also need to add the following to the Path system variable:
;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;
Taken from: https://github.com/simnova/webdevdocs/wiki/Installing-PhoneGap-and-Android-Studio-on-Windows
SDK Path also be in C:\Users\USER\AppData\Local\Android\sdk
This is what I just tried to make it work. I was in:
os x Yosemite version 10.10.2
cordova version 4.2.0
android studio 1.0.1
Java SE Development Kit 7
set path:
# on ~/.zshrc file (open a text editor)
export ANDROID_HOME="/Users/<user>/Library/Android/sdk/"
export ANDROID_TOOLS="/Users/<user>/Library/Android/sdk/tools"
export ANDROID_PLATFORM_TOOLS="/Users/<user>/Library/Android/sdk/platform-tools"
PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS
reopen terminal
install "android-19" from android SDK manager
$ android
# pick "SDK Platform Android 4.4.2, API 19"
and then go to a Cordova-based project directory
$ ionic platform add android
Android path set in linux:
$export ANDROID_HOME=/usr/lib/android-sdk-linux
$export PATH=$PATH:$ANDROID_HOME/tools
$export PATH=$PATH:$ANDROID_HOME/platforms-tools
than
$cordova run android
In Linux,
edit .bashrc file and add the ANDROID_HOME and PATH variable,
export ANDROID_HOME=/usr/local/android-sdk-linux/
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platforms-tools
After saving .bashrc file, run
source ~/.bashrc
then in type
android in a terminal
if it will run, ANDROID_HOME and PATH is set,
if you get this message,
bash: /src/android-sdk/tools/android: Permission denied
then run
sudo chmod a+x /usr/local/android-sdk-linux/tools/android
otherwise you will get same error message
Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
NB: Use your android sdk installation path instead of /usr/local/android-sdk-linux/
For Windows I just had to add an env variable pointing to the SDK folder. Done!
(The accepted answer didn´t work for me)
Only one change was needed to fix the problem:
Go to Start -> Control Panel -> System -> Advanced(tab) -> Environment Variables -> System Variables
set ANDROID_HOME to C:\Program Files (x86)\Android\android-sdk
ANDROID_HOME is deprecated now instead of using ANDROID_HOME use ANDROID_SDK_ROOT
as per Google android documentation -
ANDROID_SDK_ROOT sets the path to the SDK installation directory. Once set, the value does not typically change, and can be shared by multiple users on the same machine. 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.
For details follow this Android Documentation link
I had to close and re-open my windows console (or open a new console), and then open the SDK manager (ran android), after which a bunch of updates and installs had to complete.
For those who are working with Ionic Framework on windows and doesn't have andorid studio installed on their PCs, you must have either download Android Studio or at list download the SDK Manager.
If you choose the SDK Manager option you have to set the path for the Enviroment Variable:
Variable name: ANDROID_HOME, Variable value: the path where you installed the android SDK, in my case is, C:\Android\android-sdk.
You have to add the variable to the Path variable system by adding this:
;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;.
Then if you got the "JDK error" just download it from the Oracle website and create a system variable like the Android SDK:
Variable name: JAVA_HOME, Variable value: the path where you installed the JDK, in my case is, C:\Program Files\Java\jdk1.8.0_144. Then add it to the Path variable system by adding ;%JAVA_HOME%\bin.
Then if you got the "Gradle error" just fallow the installations steps on the official website of gradle.
Finally you can continue to creating your ionic app's apk.
Note: you have to reopen the cmd window several times or restart your pc after making those changes. Hope this work for you.
Using Android Studio on Mac, run this on your terminal:
export ANDROID_HOME=/Applications/Android\ Studio.app/sdk/
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platforms-tools
Then, when you type
android
at your terminal, it will run something
You just need to type a command in flutter_console.bat type flutter config --android-sdk <path-to-your-android-sdk-path>
Go to system properties.
Click change setting.
Click advance tab.
Click Environment Variables button.
In system variables area click new button.
Set ANDROID_HOME in the Variable name field.
Set C:\Program Files (x86)\Android\android-sdk in the Variable value field.
Click ok button.
Double click Path variable in the list.
Click new button.
Past C:\Program Files (x86)\Android\android-sdk\platform-tools in the filed.
Click new button again.
Past C:\Program Files (x86)\Android\android-sdk\tools in the field.
Press enter 3 times.
That's all you need to do.
The main reason of this would be the path ( ANDROID_HOME ) is not set in appium. You can confirm that by checking the last step first
step 1 :- Checkout the path where android sdk is located
it could be in c drive/program files or below location mostly
C:\Users\yourUserName\AppData\Local\Android\Sdk
Step2 :- Set the System variables . By typing in search bar in window (you can open this window for setting system variables)
Last step :- To confirm the problem will not repeat verify this, Open appium click on edit configuration and confirm if you can see the path set
It's is mostly with missing andriod SDK. for this issue and "JAVA_HOME" error following solution worked for me... whole day saved after following steps.
To build and run apps, you need to install SDKs for each platform you wish to target. Alternatively, if you are using browser for development you can use browser platform which does not require any platform SDKs.
To check if you satisfy requirements for building the platform:
$ cordova requirements
Requirements check results for android:
Java JDK: installed .
Android SDK: installed
Android target: installed android-19,android-21,android-22,android-23,Google Inc.:Google APIs:19,Google Inc.:Google APIs (x86 System Image):19,Google Inc.:Google APIs:23
Gradle: installed
Requirements check results for ios:
Apple OS X: not installed
Cordova tooling for iOS requires Apple OS X
Error: Some of requirements check failed
By the way, one other possibility is that you do have a too old version of cordova android platform.
Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.
Then:
cordova platform update android --save
if Linux users still have the same error, probably they have used "sudo" for adding android platform.. a quick solution for this here, or you have installed cordova using sudo, also there is a solution for this problem here.
Hope this help!
I also faced this same issue, I got a solution with this.
I did the following steps :
Open system properties
Environment variables
create a new system variable
name: ANDROID_HOME
value: copy your SDK path( Ex: my SDK path E:\SoftWares\Android-SDK)
close your current cmd, and restart it
run flutter doctor
this should work on windows
I encountered this error and I had to set the ANDROID_HOME using bash_profile.
Then run the source ~/.bash_profile before running appium from terminal.
You can set the ANDROID_HOME variable from inside Visual Studio as well:
Go to Tools->Options->Cross Platform->C++ and enter the path under Android SDK.
If nothing else works, make sure that you have correct permissions and ownership set up during building. A quick fix can be:
sudo chown -R <you>:<your_group> *
sudo chmod -R 755 *
Related
This is my PATH
export ANDROID_SDK_ROOT=/mnt/sda1/DevTools/sdk/
export ANDROID_HOME=$ANDROID_SDK_ROOT
export PATH=${PATH}:/mnt/sda1/DevTools/sdk/platform-tools
I try many cases, but still this error!
Try :
flutter doctor --android-licenses
if something wrong, try to locate android sdk path.
flutter config --android-sdk {path}
Mine :
flutter config --android-sdk C:\Android\Sdk
This worked for me. If you have sdkmanager, avdmanager and emulator, and you have them in your PATH environmental variable, then
Download a system image:
sdkmanager "system-images;android-30;google_apis_playstore;x86_64"
(you can find available packages with sdkmanager --list --verbose)
Create a new virtual device with
avdmanager create avd --name MyAndroidDevice --package "system-images;android-30;google_apis_playstore;x86_64"
Start the emulator
emulator -avd MyAndroidDevice
Now restart VSCode and open your Flutter project. The new device should be at the bottom right corner or you should be able to choose it by clicking on "No device".
For me, I had to restart my VS Code for the installation of Android SDK be reflected upon it.
I know this is an old question but setting my $PATH variable in ~/.bashrc (I'm on Ubuntu 20.04) did not work for me.
I needed to setup Android Emulator for VScode, because I wanted to run my flutter app, which seems to be the same issue as OP had.
Instead of setting the $PATH directly you can actually use Flutter in the terminal to do it.
If you run "flutter config" in the terminal you get something like:
Configure Flutter settings.
To remove a setting, configure it to an empty string.
The Flutter tool anonymously reports feature usage statistics and basic crash reports to help
improve Flutter tools over time. See Google's privacy policy:
https://www.google.com/intl/en/policies/privacy/
....
Run "flutter help" to see global options.
Settings:
android-sdk: <my_path_to_android_tools>
Analytics reporting is currently enabled.
You can then see the $PATH that is currently set with flutter under:
Settings:
android-sdk: <my_path_to_android_tools>
Mine was incorrect so I changed it to the current one with the command:
flutter config --android-sdk <my_path_to_android_tools>
Afterwards I restarted VScode and when it was finished loading I could now press the "device" button in the right hand corner and then select emulator that I had already created. I used one of the above answers to install the emulator itself.
It took a while to launch the emulator the first time due to installing some dependencies but it did work!
I tried this and works:
from terminal run flutter config --enable-android. You will get Setting "enable-android" value to "true".
after that open android studio, set up virtual devices first if you haven't. Open Android Studio -> Configure -> AVD Manager -> Create Your Virtual Device
Go back to your VS Code, open command Palette (Ctrl+P or cmd+P, then type >), or from View -> Command palette... -> Flutter: Select Device -> choose your android device
I faced the same issue and solved it running flutter doctor from the terminal, in VS Code. In my case, I had the android sdk located in a custom location (D drive), the reason why it wasn't found automatically. The "doctor" told me to run flutter config --android-sdk <my-sdk-custom-location>. Running it and restarting the IDE made the trick. Hopefully this helps someone facing the same problem.
When I run the ionic capacitor run android command, to launch my application in Android Studio, I get the error saying:
Unable to launch Android Studio." You must configure "linuxAndroidStudioPath" in your capacitor.config.json to point to the location of studio.sh, using JavaScript-escaped paths:
example:
{
"linuxAndroidStudioPath": "/usr/local/android-studio/bin/studio.sh"
}
but I configured the path my capacitor.config.json but the error persists.
Here's my capacitor.config.json file
First, run whereis android-studio in your terminal. This command will return the path of your android studio.
Mine is /snap/android-studio/current/android-studio/bin/studio.sh. I installed android-studio from the ubuntu software store. Maybe you installed it through a different source and in a different location.
Then add "linuxAndroidStudioPath": "/snap/android-studio/current/android-studio/bin/studio.sh" in capacitor.config.json which is located in the root of your project.
Replace /snap/android-studio/current/android-studio/bin/studio.sh by your path. which is returned to you by whereis android-studio
"linuxAndroidStudioPath": "/snap/android-studio/current/android-studio/bin/studio.sh" is the path.
Add sudo when running the project sudo npx cap open android
in my case, android studio location was "/opt/android-studio/bin/studio.sh"
{
...
"linuxAndroidStudioPath": "/opt/android-studio/bin/studio.sh"
}
I use JetBrains Toolbox and macOS
to open the capacitor project with Android Studio with npx cap open android I had to export the Android Studio path as follow:
export CAPACITOR_ANDROID_STUDIO_PATH="/Users/myuser/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7199119/Android Studio.app"
Set environment variable--
Step1- Run: nano ~/.bashrc in terminal.
Step2- Add export CAPACITOR_ANDROID_STUDIO_PATH="path of android-studio/bin/studio.sh" in .bashrc file.
Step3- Run npx cap open android in terminal.
I have the same issue and I didn't manage to find out why it can't verify the path for android studio.
In order to use npx cap open android i had to open Android Studio before running the command.
Open your terminal and run gedit .bashrc.
Set the environment variable:
export CAPACITOR_ANDROID_STUDIO_PATH="path of android-studio/bin/studio.sh"
Save your file with Ctrl+s.
This will read your capacitor directly by running
Ionic cap open android
All of the answers here are on point, however I would like to add something small to note.
Its worth noting that Android Studio has different installation locations depending on the distribution you are using and also some installations are command-line based others are offline installations.
Some well known places are:
/usr/local
/usr/share
/opt
Lastly whereas the commands to search for android-studio may work in some instances where the default installation path was not changed. However the command
whereis android-studio
will not return anything in a case where the directory name is not the default i.e
/opt/android-studio-2021.2.1/android-studio/bin/studio.sh"
or
/usr/local/android-studio-2021.2.1/bin/studio.sh"
Here's how I solved this: In Ionic 6x, there's no capacitor.config.json. You'd have to set an environment variable of CAPACITOR_ANDROID_STUDIO_PATH globally. Do this by typing
export CAPACITOR_ANDROID_STUDIO_PATH=/path/to/android-studio/studio.sh
Worth noting that my Android Studio is found at /opt/android-studio/bin and not under /snap/...
Everything looks correct so the likely answer is that you have got the path wrong somehow.
Could you recheck it?
Also, are you running the latest versions of everything?
I am trying to setup Flutter in windows 10.
I have:
Android Studio installed
Visual Studio Code
When I run "andoid doctor" in command prompt is shows no errors:
But When I try to configure VSCode Editer with steps given in https://flutter.io/get-started/editor/
It Throws error as show below:
I tried after setting environment variable as:
ANDROID_HOME = F:\Program Files\Android
Even after setting the above I get the same error.
My device was not getting detected by VS Code so , when i searched i found you need to set Android sdk location in Flutter environment for VS code to detect Device so i went to Flutter sdk folder C:\Research\flutter and double clicked on flutter_console which opened a Flutter console and run command
flutter config --android-sdk C:\Users\annur.arya\AppData\android-sdk and now it works
I just added a solution because the solution is not clear in the comments
You have to use this command to set the ANDROID_HOME to your SDK path
export ANDROID_HOME="YOUR_SDK_PATH"
According to this discussion, some people had to set both ANDROID_HOME and ANDROID_SDK_ROOT to SDK path just like this
export ANDROID_SDK_ROOT="YOUR_SDK_PATH"
export ANDROID_HOME=$ANDROID_SDK_ROOT
It's possible that ANDROID_HOME is not set to the same value in both of these cases; try running echo %ANDROID_HOME both in the location that works and the terminal where it doesn't. If these values are different, you'll need to figure out why (my guess would be that either you've changed it and not rebooted, or it's being set in a startup script that's only running in one of the contexts).
I had the same problem,
I did the following steps :
*/ Open system properties
*/ Environment variables
*/ create new system variable
*/ name : ANDROID_HOME
*/ value : copy your SDK path
*/ close your current cmd, and restart it
*/ run flutter doctor
this should work on windows
You can look in ~/.config/flutter/settings in Linux to manually configure the folder.
GO to Project Structure
set Project SDK to 31 API Or any one 30,29 etc..
and then click Ok
I installed Android Studio on Linux Mint 17.2, but when I open up a terminal window and echo $GRADLE_HOME, nothing is set. Should it be set? If it should be, how would I find where it is located so I can manually set it myself?
Thx
The Gradle installed via Android Studio will only be available only within Android Studio. I may be wrong here, since I never used Android Studio. However, if you want Gradle available outside of Android Studio you may have to install manually. Check out the Gradle Documentation. Once you installed set the Gradle home in /etc/environment file (There are several files in which you can set this, but this is my preference since it makes the variable available to all users). Add the installation location to that file. You may choose to install in a different location.
GRADLE_HOME=/usr/local/gradle-2.13
After you add add bin location to PATH variable. Eg:
PATH=...:$GRADLE_HOME/bin
Since you are adding the GRADLE_HOME in /etc/environment file you may have to restart your PC after adding.
The Android Studio zip bundles gradle. After unpacking the zip it is located in android-studio/gradle/gradle-x.x/bin (assuming the unpack directory is android-studio). In my case with Android Studio 3.1 the gradle version was gradle-4.4
so setting GRADLE_HOME to /path/to/unpackdir/gradle/gradle-4.4 should work.
Then add $GRADLE_HOME/bin to your path and you should be set.
You might have to chmod +x gradlew (for example if you use cordova and want to install a plugin)
I am using Android Studio. I can't open Android Device Monitor, Tools > Android > Android Device Monitor. I occurred an error. See the log file at:
C:\Users\Peter Phyo\AppData\Local\Android\sdk\tools\lib\monitor-x86\configuration\1433318221838.log.
Do you have JAVA_HOME in your system environment variables?
JAVA_HOME=C:/Program Files/Java/jdk1.8.0_11
Run android studio as administrator. It will definitely work. No need to reinstall neither android studio nor java.
In my case, after upgrading Android Studio 3.1.2, I tried open C:\Users\yourUserName\AppData\Local\Android\Sdk\tools\monitor, Windows alert "can't find 'lib\monitor-location'. Make sure you typed the name correctly, and then try again". Then I tried open tools\lib\monitor-x86_64\monitor, it works!
I'm on Windows and open Android Studio in Administrative Mode (Run as administrator). Worked for me.
I had the same problem, i solved it using jPortable, if you're using Windows then take this one, there are two versions 32bits and 64bits : https://portableapps.com/apps/utilities/java_portable I changed the location for the extraction from C:\SDK\tools\lib\monitor-x86_64\CommonFiles\Java64 to C:\SDK\tools\lib\monitor-x86_64\jre and it worked.
You need to set path to your ..jre\bin location :
Check in: File > Project Structure your JDK location
add the \bin there , my path is : C:\Program Files\Android\Android Studio\jre\bin
set the path in your Environment Variables, for WINDOWS 7 :
the From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click Environment Variables
New System Variable
set the path the following way :
Variable name: Path
Variable value: your path
in my case: Variable value: C:\Program Files\Android\Android Studio\jre\bin
Now you can start the Monitor.exe, my location is here : C:\Users\Admin\AppData\Local\Android\Sdk\tools\lib\monitor-x86_64
for WIN7 32bit start the Monitor.exe from
...Android\Sdk\tools\lib\monitor-x86
Make sure have installed JDK7 or JDK8 depending on your OS bits
If you are using 32bits your install JDK7 or 8 of 32bits
After you install JDK, your JAVA_HOME in your system will be located in
C:\Program Files\Java\jdk1.8.0_40
To check if your JAVA_HOME is set, CLICK Start Menu > Computer > Right Click on Computer > Properties > Control Panel Home will appear, > click Advanced System Settings, under > Advanced Tab click > Environment Variables and check on the > System Variables for > Path if Java [C:\ProgramData\Oracle\Java\javapath;] is there, than you are good to go.
Make sure you have your JAVA_HOME in your system environment variables.
Hope this well help you. If it helped you, please mark it, so that it can the useful to others.
Please ensure you have Android SDK Tools installed.
I had a fresh copy of Android Studio and kept getting this error.
To install:
Tools -> Android -> SDK Manager -> SDK Tools (tab) -> Tick Android SDK Tools x.x.x (if it's not installed) -> Apply
Once installed / finished, try restarting Android Studio then selecting Android Device Monitor from the Tools drop down again.
If you want to see file explorer the please go from this path
View -> Tool Windows -> Device File Explorer.
I hope this path solve your problem.