I am trying to run UiAUtomatorViewer from command prompt on Windows10 machine. But it keeps giving the following error when I run uiautomatorviewer.bat from the Sdk\tools\bin directory.
-Djava.ext.dirs=..\lib\x86_64;..\lib is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
(image of above error for reference)
JAVA_HOME, ANDROID_HOME environment variables are set and I am able to use adb commands like adb devices etc well.
I also added Java install directory to the PATH variable. Any suggestions?
Downgrade your Java version to "1.8.0_231"
you can get here: https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html
set the env in your bash_profile. to do that -
go to MAC DISK and find ".bash_profile"
Open,edit and put the path
example:
export ANDROID_HOME=~/Library/Android/sdk
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin
export PATH=$PATH:$JAVA_HOME/lib
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/build-tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/tools/lib/x86_64
quit the terminal and reopen
type "uiautomatorviewer" and hit enter
that it.
In command prompt type following on Window machine
go to the bin directory
**cd C:\Users\<username>\AppData\Local\Android\Sdk\tools\bin>**
Set JAVA_HOME on command prompt by typing
**set JAVA_HOME = C:\Program Files\Android\Android Studio\jre**
then run UIAutomator,
uiautomatorviewer.bat
Note : The set command does not save values between cmd.exe sessions. So JAVA_HOME is set to above temporary. So every time you need to do above steps for new cmd.exe sessions.
I set the ANDROID_HOME in .bash_profile and run source ~/.bash profile but after close and open the terminal back then run echo $ANDROID_HOME return blank
.bash_profile
source ~/.bash_profile
export PATH="/usr/local/opt/openssl/bin:$PATH"
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export ANDROID_HOME=/Users/Najibah/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platfrom-tools
This happened when I run echo $ANDROID_HOME
Remove source ~/.bash_profile from the .bash_profile file, because it leads to a loop. You only need to run the command from the terminal in order to load an updated version of the file. New terminal windows will use the latest version of the file anyway.
After changing the .bash_profile, run source ~/.bash_profile from your terminal window, and then run echo $ANDROID_HOME. You should get the expected value.
Directory should be wrapped in double quotes.
Change JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home
like this JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home"
I stack with it too. .bashrc editing not claim success. Answer is here: https://askubuntu.com/a/60221/965574 you need to add strings to the .profile file
When I run tns run android or tns doctor I get an error that the ANDROID_HOME environment variable is not set. Yet it's clearly set. Mac OSX Sierra 10.12.3.
bash-3.2$ tns run android
The ANDROID_HOME environment variable is not set or it points to a non-existent directory. You will not be able to perform any build-related operations for Android.
bash-3.2$ $ANDROID_HOME
bash: /Users/rlangton/Library/Android/sdk: is a directory
bash-3.2$
Open/create .profile like this
vim ~/.profile
add the following lines to the end of the .profile file.
export ANDROID_HOME=${HOME}/Library/Android/sdk
load the profile using the command
source ~/.profile
You should have it working I guess. This is what I did to get this configured.
If you're using bash then you need to update the ~/.bash_profile file.
In my case, I'm using ZSH so I needed to edit ~/.zshrc file.
nano ~/.zshrc
Add the export line below:
if [ -f /Users/{myusername}/.tnsrc ]; then
source /Users/{myusername}/.tnsrc
export ANDROID_HOME=/Users/{myusername}/Library/Android/sdk
fi
Ctrl + O to save, Ctrl + X to exit. Restart the terminal. Now echo $ANDROID_HOME shows the correct path every time.
How to set ANDROID_HOME path in ubuntu?
Please provide the steps.
In the console just type these :
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
If you want to make it permanent just add those lines in the ~/.bashrc file
I would like to share an answer that also demonstrates approach using the Android SDK provided by the Ubuntu repository:
Install Android SDK
sudo apt-get install android-sdk
Export environmental variables
export ANDROID_HOME="/usr/lib/android-sdk/"
export PATH="${PATH}:${ANDROID_HOME}tools/:${ANDROID_HOME}platform-tools/"
Assuming you have the sdk extracted at ~/Android/Sdk,
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Add the above lines to the file ~/.bashrc (located at home/username/.bashrc) to make it permanent for the current user. Run source ~/.bashrc to apply the changes or restart your terminal.
(or)
Run the above lines on a terminal window to make it available for the session.
To test if you have set it up correctly,
Run the below commands on a terminal window
echo $ANDROID_HOME
user#host:~$ echo $ANDROID_HOME
/home/<user>/Android/Sdk
which android
user#host:~$ which android
/home/<user>/Android/Sdk/tools/android
Run android on a terminal window, If it opens up Android SDK Manager, you are good to go.
better way is to reuse ANDROID_HOME variable in path variable. if your ANDROID_HOME variable changes you just have to make change at one place.
export ANDROID_HOME=/home/arshid/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Initially go to your home and press Ctrl + H it will show you hidden files now look for .bashrc file, open it with any text editor then place below lines at the end of file.
export ANDROID_HOME=/home/varun/Android/Sdk
export PATH=$PATH:/home/varun/Android/Sdk/tools
export PATH=$PATH:/home/varun/Android/Sdk/platform-tools
Please change /home/varun/Android/Sdk path to your SDK path.
Do the same for tools and platform-tools.
After this save .bashrc file and close it.
Now you are ready to use ADB commands on terminal.
Add the following to your ~/.bashrc file. Log-out and log-in. I have my sdk in $HOME/Documents/Android/sdk you have to replace it with where you keep your sdk folder
# Android Path
PATH=$PATH:$HOME/Documents/Android/sdk:$HOME/Documents/Android/sdk/tools
export PATH
# For SDK version r_08 and higher, also add this for adb:
PATH=$PATH:$HOME/Documents/Android/sdk/platform-tools
export PATH
first open the .bashrc file by gedit ~/.bashrc
# Added ANDROID_HOME variable.
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
save the file and reopen the terminal
echo $ANDROID_HOME
it will show the path like /home/pathTo/Android/Sdk
Applies to Ubuntu and Linux Mint
In the archive:
sudo nano .bashrc
Add to the end:
export ANDROID_HOME=${HOME}/Android/Sdk
export PATH=${PATH}:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools
Restart the terminal and doing: echo $ HOME or $ PATH, you can know these variables.
Download the Android SDK to the machine. (Suppose that the location is /home/zelong/Android/Sdk) (home/username/Android/Sdk)
Add these lines to the file ~/.bashrc (located at home/username/.bashrc)
export ANDROID_HOME="/home/zelong/Android/Sdk"
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
This will make it permanent for the current user because every time the machine boots, it will run this script and set the enviroment path.
After making this change, remember to save it.
Then run source ~/.bashrc to apply the changes or restart your terminal.
Test if it works:
zelong#zelong-ThinkPad-T430:~$ echo $ANDROID_HOME
/home/zelong/Android/Sdk
zelong#zelong-ThinkPad-T430:~$ which android
/home/zelong/Android/Sdk/tools/android
zelong#zelong-ThinkPad-T430:~$ which adb
/home/zelong/Android/Sdk/platform-tools/adb
As we can see,
android command line locates under tools
adb command line locates under platform-tools
This is what work for me,
Assuming you have the sdk extracted at ~/Android/Sdk,
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Add the above lines to the file ~/.bashrc (located at home/username/.bashrc) to make it permanent for the current user. Run source ~/.bashrc to apply the changes or restart your terminal.
(or)
Run the above lines on a terminal window to make it available for the session.
To test if you have set it up correctly,
Run the below commands on a terminal window
echo $ANDROID_HOME
user#host:~$ echo $ANDROID_HOME
You will get
/home/<user>/Android/Sdk
You can run this too
which android
user#host:~$ which android
/home/<user>/Android/Sdk/tools/android
Run android on a terminal, If it opens up Android SDK Manager, you are good to go.
you can edit the environment variable file in Ubuntu to set android home globally.
[1] run this command in terminal
sudo -H gedit /etc/environment
[2] your envirmnent file content will look like the below one
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
[3] in environment file add android sdk path as follows:-
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
ANDROID_HOME="/home/yourPathTo/Android/Sdk"
[4] then you can check the Android home path in the terminal with the following command:-
echo $ANDROID_HOME
If path is still not set then restart the system to get the applied changes.
In my case it works with a little change. Simply by putting :$PATH at the end.
# andorid paths
export ANDROID_HOME=$HOME/Android/Sdk
export PATH="$ANDROID_HOME/tools:$PATH"
export PATH="$ANDROID_HOME/platform-tools:$PATH"
export PATH="$ANDROID_HOME/emulator:$PATH"
In the terminal just type these 3 commands to set the ANDROID_HOME Variable :
$ export ANDROID_HOME=~/Android/Sdk
/Android/Sdk is the location of Sdk, this might get change in your case
$ PATH=$PATH:$ANDROID_HOME/tools
$ PATH=$PATH:$ANDROID_HOME/platform-tools `
Note : This will set the path temporarily so what ever action
you have to perform, perform on the same terminal.
If you run android with sudo it will install sdk in /root/Android/Sdk
so check if that is the case.
And if you are using dont run cordova with sudo it will look sdk in root also may be.
Above code for setting path is works fine.
I was facing the same problem with linux ANDROID_HOME path
Note:
1- Add parameters
2- Make or Rebuild project
3- Restart your PC
How to add parameters using terminal:
Open your terminal write
gedit .bashrc
another window will be open and then add the following lines at the end of the windows.
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
then back to terminal and type
source .bashrc
to save your changes in bashrc file at the end restart your computer.
add to file
~/.profile
export ANDROID_HOME=/opt/android-sdk
Path to the SDK
Then reset the computer
Had the same issue,
in the terminal you can type:
export ANDROID_HOME=$HOME/Android/Sdk
or any other location depending on where you installed the sdk.
export PATH=$PATH:$ANDROID_HOME/platform-tools
Hope it helps!
sudo su -
gedit ~/.bashrc
export PATH=${PATH}:/your path
export PATH=${PATH}:/your path
export PATH=${PATH}:/opt/workspace/android/android-sdk-linux/tools
export PATH=${PATH}:/opt/workspace/android/android-sdk-linux/platform-tools
You can append this line at the end of .bashrc file-
export PATH=$PATH:"/opt/Android/Sdk/platform-tools/"
here /opt/Android/Sdk/platform-tools/ is installation directory of Sdk.
.bashrc file is located in home folder
vi ~/.bashrc
or if you have sublime installed
subl ~/.bashrc
open ~/.bashrc file and paste at the end
export PATH=$PATH{}:/path-from-home-dir/android/sdk/tools
export PATH=$PATH{}:/path-from-home-dir/android/sdk/platform-tools
hi i am using ubuntu 12.04. and in ~/.bashrc file I set following things
export ANDROID_HOME=/home/nilkash/Downloads/android-sdk-linux/platform-tools
But still it gives me android: command not found error. how to set path for android. Need Help. Thank you.
To include the SDK's tools and platform-tools directories in your PATH environment open text editor to create or modify the ~/.bash_profile file, adding below line:
export PATH=${PATH}:/home/nilkash/Downloads/android-sdk-linux/platform-tools:/home/nilkash/Downloads/android-sdk-linux/tools
For Ubuntu:
To modify the PATH variable of your system, you need to edit your .bashrc file. To do so, in a terminal, execute the following command:
$ nano ~/.bashrc
You will now have the Nano text editor enabled on the terminal. Now, at the very top of the file, enter the following:
#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
Once you're finished, press CTRL + X, Y, and then hit Enter to save your changes and exit the Nano text editor.
To reload the ~/.bashrc without re log in:
. ~/.bashrc or source ~/.bashrc
References:
- help.ubuntu.com/community/AndroidSDK- How do I reload .bashrc without logging out and back in?
1) Check in System Settings -> Details, whether your Ubuntu is 32-bit or 64-bit
2) If your Ubuntu is a 32-bit OS then run this sudo apt-get install libgl1-mesa-dev
In case of 64-bit OS run this sudo apt-get install ia32-libs
3) run this sudo apt-get install openjdk-6-jdk or better this sudo apt-get install openjdk-7-jdk
4) Download SDK platform tools from here http://developer.android.com/sdk/index.html
5) Unzip downloaded file "adt-bundle-linux-x86_64-20131030.zip" (you can have a little bit different name ;). But you should get folder contained two sub folder - sdk and eclipse
6) Run this nautilus ~
7) In opened window create folder 'android-sdk-linux'
8) copy the all entire contents of folder sdk (from unzipped archive) to this new folder 'android-sdk-linux'
9) try run this cd ~/android-sdk-linux/tools then this ./android. If you did all right you should see Android SDK Manager
10) run this sudo gedit ~/.bashrc in opened editor add this in very top
#AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
11) save and close
12) run exec bash then try run android
13) give write permissions to android-sdk-linux folder
Enjoy! ;)
android: command not found error
Solution for Linux and Mac:
1) Export your Android Sdk path to the ANDROID_HOME variable
$ export ANDROID_HOME=~/Android/Sdk (where ~/Android/Sdk is a full path to your Sdk folder)
(change "~" to "$HOME" on Mac)
2) Export Sdk tools to the PATH variable
$ export PATH=$ANDROID_HOME/tools:$PATH
That's it!
I tried
sudo nano /etc/profile
and appended these after the fi
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export ANDROID_HOME=/home/dev/Android/Sdk
export PATH=$PATH:$JAVA_HOME/bin:$ANDROID_HOME/platform-tools:ANDROID_HOME/tools
export JAVA_HOME
export ANDROID_HOME
and after saving the file
exec bash
these got my android command working, I had set PATH in .bashrc which was not working for me
Hope It'll help somebody
Environment variables can be defined permanently by editing the .profile file in your home directory. Here's how:
Edit your .profile file with a command like gedit ~/.profile. Append this to the end of the file:
export ANDROID_SDK_HOME=/home/nilkash/Downloads/android-sdk-linux/platform-tools
You can source .profile to make it apply right away. Each time you restart your system, the .profile file is loaded, restoring this setting.
OR
This below method works 100% for me on Ubuntu 12.04:
Start the terminal
$gedit .bashrc
Add the below line at the enc of the file:
PATH=$PATH:/home/nilkash/Downloads/android-sdk-linux/platform-tools/
Note: gedit must be performed only on .bashrc and NOT on .bashrc~
Please do accept the answer if it works for you.
if the problem still exist please make sure that you have the right permissions
try
sudo chmod -R 777 /home/your-user-name/.cordova/
Also make sure that you are NOT using sudo to add Android as a platform
This is incorrect in the default Cordova installation
sudo cordova platform add android
Just do
cordova platform add android