How to install ANDROID_SDK_ROOT on Mac OS? - android

Good day. I can not understand how to install ANDROID_SDK_ROOT variable for the Mac OS.
Search on stackoverflow already made, the code on recommendations tried to use - nothing.
I installed Android Studio by standard, my SDK has path /Users/admin/Library/Android/sdk/
vim ~/.bash_profile
export ANDROID_HOME=/Users/admin/Library/Android/sdk
export ANDROID_SDK_ROOT=/Users/admin/Library/Android/sdk
export ANDROID_AVD_HOME=/Users/admin/.android/avd
source ~/.bash_profile
When you try to build an application in Cordova the same result:
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/admin/Library/Android/sdk (DEPRECATED)
Requirements check failed for JDK 8 ('1.8.*')! Detected version: 13.0.1
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.

First, after configuring your .bash_profile be sure to open a new terminal session so the environmental variables get picked up.
Assuming you've tried that already, you may want to consider installing the Android development kit through Homebrew - a package manager for MacOS. Once you have everything set up there, you can then run
$ brew install gradle
$ brew install android-sdk
Homebrew will then add the appropriate variables to your .bash_profile
If that all still proves to be of no avail, try setting your JAVA_HOME variable to be:
export JAVA_HOME="$(/ur/libexec/java_home -v 1.8)

Related

WARNING: The Android SDK is not installed or is not configured properly

Problem
Under Windows Subsystem Linux (WSL) running tns doctor or any other tns command results with:
WARNING: The Android SDK is not installed or is not configured properly.
Solution
Go to android-sdk on your system.
Rename emulator/emulator.exe to emulator.
Download platform-tools for linux (exact same version as for windows) and merge windows platform-tools with linux platform-tools.
Make sure you use proper version of java for NativeScript.
Make sure you properly set environmental variables in .bashrc under WSL (in my case):
export ANDROID_HOME='/mnt/d/Android/sdk'
export JAVA_HOME='/usr/lib/jvm/java-8-openjdk-amd64'
export PATH=$PATH:$ANDROID_HOME/platform-tools

Cannot build ionic project due to ANDROID_HOME path issues

I use linux mint. I set the path on ~/.bash_profile like:
export ANDROID_HOME=/home/mss/android-sdks
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
When I build ionic project on android :-
lenovo-g50 ~/IONIC/apps $ cordova run android
Running command:
/home/mss/IONIC/apps/hooks/after_prepare/010_add_platform_class.js /home/mss/IONIC/apps
Add to body class: platform-android
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.
in windows OS
set PATH=%PATH%;C:\Users\userName\AppData\Local\Android\android-sdk\tools;C:\Users\userName\AppData\Local\Android\android-sdk\platform-tools
IN mac
export PATH=${PATH}:/Users/userName/Documents/android-sdk-mac_x86/platform-tools:/Users/userName/Documents/android-sdk-mac_x86/tools
You have to download the sdk. I think your environment variable are set properly, but you don't have the required SDK. type android -v in your console and it start the SDK manager or you can start it manualy in ANDROID_HOME directory. You need to install several build tools and in minimum one SDK Platform.

Meteor 1.2 Failed to find ANDROID_HOME

Problem: Meteor cannot find my Android SDK when I try to meteor add-platform android on Linux Mint.
I've set my PATH variable: (echo $PATH)
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/jimmy/Android/Sdk/tools:/home/jimmy/Android/Sdk/platform-tools
I've got my ANDROID_HOME variable: (echo $ANDROID_HOME)
/home/jimmy/Android/Sdk
But still, when I run sudo meteor add-platform android --verbose I get:
Adding platform Android to Cordova project
% Adding android project...
android: added platform
Checking Cordova requirements for platform Android
Your system does not yet seem to fulfill all requirements to build apps for
Android.
Please follow the installation instructions here:
https://github.com/meteor/meteor/wiki/Mobile-Development-Install:-Android-on-Linux
Status of the requirements:
✓ Java JDK
✗ Android SDK: Failed to find 'ANDROID_HOME' environment variable. Try setting
setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to
include path to valid SDK directory.
✗ Android target: Android SDK not found. Make sure that it is installed. If it
is not at the default location, set the ANDROID_HOME environment variable.
✗ Gradle: Could not find gradle wrapper within Android SDK. Could not find
Android SDK directory.
Might need to install Android SDK or set up 'ANDROID_HOME' env variable.
Okay, so I figured it out? (I guess)
So, I had already had my PATH and ANDROID_HOME set and everything, I could do echo $PATH and echo $ANDROID_HOME and it would print fine; but when I would run the different commands, it wouldn't work.
however, when I run sudo -s and then the commands, it works fine.
Cheers
ANDROID_HOME must be set to Android/Sdk folder. In my case (Ubuntu) it is:
export ANDROID_HOME="/home/***<user name>***/Android/Sdk"
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Put this lines at the end of ~/.profile:
$ gedit ~/.profile
Then $ source ~/.profile
I had the same issue (and now I am stuck to Android target), but to solve Android SDK,
go to Android studio and ensure you remove everything from Android 6,
then that you have Android 5.1.1 installed (with v22 of the platform),
restart your console (I had to restart the laptop)
and normally it doesnt appear again (btw you dont need to use sudo normally)
It's possible that since you're using SUDO - that the PATH / ANDROID_HOME are not present in the root user's session. So try either:
sudo -s
export PATH=...
export ANDROID_HOME=...
meteor ...
or avoid using sudo.

Where is android_sdk_root? and how do I set it.?

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.

Error to run Android Studio

I have installed Android Studio and I followed all steps described here
But when I start studio.sh I got an error with this message:
'tools.jar' is not in Android Studio classpath. Please ensure JAVA_HOME points to JDK rather than JRE
Can anyone here help me with this?
Check if your Java JDK is installed correctly
dpkg --list | grep -i jdk
If not, install JDK
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update && sudo apt-get install oracle-java8-installer
After the installation you have to enable the jdk
update-alternatives --display java
Check if Ubuntu uses Java JDK 8
java -version
If all went right the answer should be something like this:
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
Check what compiler is used
javac -version
It should show something like this
javac 1.8.0_91
Finally, add JAVA_HOME to the environment variable
Edit /etc/environment and add JAVA_HOME=/usr/lib/jvm/java-8-oracle to the end of the file
sudo nano /etc/environment
Append to the end of the file
JAVA_HOME=/usr/lib/jvm/java-8-oracle
You will then have to reboot, you can do this from the terminal with:
sudo reboot
In case you want to remove the JDK
sudo apt-get remove oracle-java8-installer
sudo apt-get install default-jdk
That's all in ubuntu 11
This is caused by having JAVA JRE installed as opposed to JAVA JDK.
The solution is simple:
sudo apt-get install openjdk-7-jdk
http://www.maxmakedesign.co.uk/development/2013/android-studio-tools-jar-classpath/
The error is self explanatory, you need to set your environment variable to JDK path instead of JRE here is it
JDK_HOME: C:\Program Files\Java\jdk1.7.0_07
check the path for linux
and here is possible duplicate Android Studio not working
Widows 7 64 bit.
JAVA_HOME point to my JRE (NOT JDK) directory
Coping of tools.jar from JDK\lib directory to ANDROIDSTUDIO\lib directory solve the problem
in OpenSuSE 13.1 and some 13.2 versions you also need to:
install java-1_7_0-openjdk-devel package
change the JAVA_HOME path when starting the studio:
For x86:
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0/ sh studio.sh
For x64:
JAVA_HOME=/usr/lib64/jvm/java-1.7.0-openjdk-1.7.0/ sh studio.sh
I had the same problem on a new installed Linux Mint 16. To fix this you just need to type command
sudo apt-get install openjdk-7-jdk
And that's it. You even do not need to add repositiries or creating JAVA_HOME in your environment.
On ubuntu I have tried all the methods that are described here but none worked.
What I did in the end was to:
download JDK from oracle, extract the archive
edit android-studio/bin/studio.sh and add at the top
export JAVA_HOME=/path/to/jdk
save the file and cd android-studio/bin and launch Android Studio: ./studio.sh
For me, running Fedora 22 with Gnome 16.2, this solution helped me.
In short, you should install the java-1.8.0-openjdk-devel, the development files of the JDK.
Open the Terminal and search for the latest version of the JDK development package:
$ dnf search jdk-devel
Last metadata expiration check performed 12:44:51 ago on Mon Aug 3 22:20:24 2015.
============================ N/S Matched: jdk-devel ============================
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment with
: full debug on
$ sudo dnf install java-1.8.0-openjdk-devel
First check if the Java JDK is installed correctly:
dpkg --list | grep -i jdk
If not, install the JDK:
Download the latest version of the JDK from Oracle: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Extract it to the appropriate location in your machine. Get the extract location:
vi ~/.bashrc or vi ~./ bash_profile
JAVA_HOME=/home/user/installs/jdk1.7.0_40
PATH=$JAVA_HOME/bin
source ~/.bashrc or source ~/.bash_profile
After the installation you can check it:
java -version
which java
If all things are correct then the right the answer should be something like this:
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)
Append the following statement to studio.sh the file in android-studio/bin directory:
JAVA_HOME=/home/user/installs/jdk1.7.0_40
Finally start your Android Studio with the following command:
./studio.sh
The problem is a bug on Fedora 20. The bug is very odd: if I have Google Talk plugin installed then Eclipse crashes (https://bugs.eclipse.org/bugs/show_bug.cgi?id=334466). It's crazy for me. I thought that was Java version and with Java 6 my eclipse was still crashing. To solve this I should use gnome/GTK instead KDE. Now it works "well" (in gnome environment). Thanks for all answers.
I was facing similar problem on Windows 7 x64 professional edition. Please note following steps to fix this problem.
tools.jar is missing from required path if you are using jdk1.7 x64 bit version.
Please install x86 version of jdk1.7
Set JDK_HOME="C:\Program Files (x86)\Java\jdk1.7.0_67" and update path environment variable as path="C:\Program Files (x86)\Java\jdk1.7.0_67\bin"
Note: Linux put the proper path.
Launch 32 bit application from /android-studio\bin folder.
I tested and verified these steps on windows 7 with 32 bit jdk1.7
It's probably because you don't have jdk installed in your machine. I had exact same problem in first run. Open a terminal (CTRL+ALT+T) and type: sudo apt-get install openjdk-7-jdk
When done setup Java environment variable. Steps as follows:
sudo gedit /etc/environment
Either in the beginning or end of the file write: JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386 (location may vary depending on the installation of your Java)
export JAVA_HOME
save and exit editor.
Load the path variable again using the terminal: . /etc/environment
Couple of helpful links for further clarifications:
How to install JDK on Ubuntu (Linux)?
How to set JAVA_HOME for OpenJDK?
Hope this helps.
On Windows 7 just run the studio.bat file in your android-studio/bin folder with right click as an administrator. Now you get ask to import previous studio settings. Ignore this and on the next dialog you can specify the path to your jdk directory.
That's all.
Marcel
I ran into this issue when I was referencing
[drive]:\Program Files\Java\jdk1.8.0_65
in my JAVA_HOME environment var instead of the Android Studio recommended
[drive]:\Program Files\Java\jdk1.7.0_79.
I am using the x64 version of the JDK on Windows 10 Pro.
From the Android Studio installation instructions.
Before you set up Android Studio, be sure you have installed JDK 6 or higher (the JRE alone is not sufficient)—JDK 7 is required when developing for Android 5.0 and higher. To check if you have JDK installed (and which version), open a terminal and type javac -version. If the JDK is not available or the version is lower than version 6, download the Java SE Development Kit 7
http://developer.android.com/sdk/installing/index.html?pkg=studio
You have 2 things you must check:
verify that /etc/environment file has the correct JAVA_HOME and PATH values referring to your Java installation directory.
verify that you have the correct Java version (maybe you are using a distribution of Linux which need a server version of Java) you may need this version like my case JRE for server.
On my Linux Mint 17.3 install, I found these instructions incredibly helpful.
The problem seems to boil down to the system's default Java being OpenJDK and Android Studio preferring Oracle's JDK. I actually did not perform the OpenJDK removal steps given in the tutorial, but only downloaded the Oracle JDK and set it as my system's default. Android Studio worked right away.
In case the linked page ever goes away, the steps I took were
Download Oracle JDK. Mine was version 1.7.0_79.
tar -zxvf jdk-7u79-linux-x64.tar.gz
sudo mkdir -p /opt/java
sudo mv jdk1.7.0_79 /opt/java
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.7.0_79/bin/java" 1
sudo update-alternatives --set java /opt/java/jdk1.7.0_25/bin/java
and
java -version
confirms the system is using Oracle's JDK, giving output like
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

Categories

Resources