MAC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT - android

I'm having the problem that I can't start an emulator in android studio.
I get these errors:
20:06 Emulator: PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT
20:06 Emulator: Process finished with exit code 1
I read that I need to change something in vim ~/.bash_profile. I tried it but it didn't work. It currently looks like this:
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
# added by Anaconda3 5.2.0 installer
export PATH="/Users/jonas/anaconda3/bin:$PATH"
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
export ANDROID_HOME=/usr/local/share/android-sdk
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
export ANDROID_HOME=/usr/local/share/android-sdk
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home
export ANDROID_HOME=/usr/local/share/android-sdk
export ANDROID_SDK_ROOT=/usr/local/share/android-sdk
Please note that I don't have any idea what vim ~/.bash_profile does or what I have changed in it lol.
I also tried uninstalling the emulators and android studio itself but it didn't work. Can I maybe clean something to complete the whole android sdk?
btw I'm on Mac.
Any ideas what I could do?

I saw all the posts about updating your bash, but it seemed you should be able to set that from within Android Studio.
Preferences > System Settings > Android SDK
One of the items in this pane lists the file system path to the android SDK, typically in your home directory (user folder). There may also be \ a list of SDK versions supported, such as Android Q, Android Pie (version 9), etc.
The first time I added an emulator I tried oreo and got the PANIC error.
I created a new one, and used Q, which according to the list i described was installed (the others, including oreo were not)
When I launched the emulator, I got my 'Hello World' example app.
So I think that if you are creating an emulator, it needs to be in sync with what you have installed.

you need to define your ANDROID_SDK_ROOT and ANDROID_AVD_HOME.
open your terminal and type open -a TextEdit ~/.bash_profile
Add this 2 line and change {your user} by your current
user :
export ANDROID_SDK_ROOT=/Users/{your user}/Library/Android/sdk
export ANDROID_AVD_HOME=/Users/ryadahitdep/.android/avd
3. CMD + S to save your changes

Related

Could not find aapt with appium server

I am currently trying to run a test on an android emulator device with appium,
everything goes fine, appium unlocks the screen of the device but then I have this error:
[ADB] Error: Could not find aapt Please set the ANDROID_HOME environment variable with the Android SDK root directory path
I set the ANDROID_HOME varaibale im my bash file to :
export ANDROID_HOME=/home/tar/android/android-sdk-linux/
and I also set the other variables to :
export ANDROID_SDK_HOME=/home/tar/android/android-sdk-linux
export PATH=${PATH}:/home/tar/android/android-sdk-linux/platform-tools
export PATH=${PATH}:/home/tar/android/android-sdk-linux/tools
But I am still facing the same error,
does someone have an idea how to solve this please?
Thank you
First make sure that you've got the SDK installed correctly and that your path in ANDROID_HOME points to the folder containing the /bin folder.
Then try running:
source ~/.bashrc
or log-in and log-out to apply the new changes in the bash file.
You could also reuse your ANDROID_HOME variable:
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools
This way you don't have to change all the variables if the location of the SDK changes.
For Windows:
Open My Computer Properties
Click on 'Advanced System Setting'
Click on 'Environment Variables..'
Create Variable for User and System both
Restart the IDE.!
Please look the image below:
sudo nano ~/bash_profile and add:
export ANDROID_HOME=/home/tar/android/android-sdk-linux/
export ANDROID_SDK_HOME=/home/tar/android/android-sdk-linux
export PATH=${PATH}:/home/tar/android/android-sdk-linux/platform-tools
export PATH=${PATH}:/home/tar/android/android-sdk-linux/tools
In recent versions of Android Studio SDK, aapt is not in tools nor in platform-tools but in build-tools. You need to add it to your PATH for Appium to find it.
export PATH="$ANDROID_HOME/build-tools:$PATH"
Copy aapt.exe from build-tools to platflorm-tools. Also make sure to add ANDRIOD_HOME to sdk folder in Windows Environment variables. This solved my problem.

How to set NDK Build path in OSX for Android studio

I had set the ANDROID_NDK_HOME as /Users/Shajilshocker/Documents/Android/NDK/android-ndk-r10b using a mac osx application called Environment Variables.
I had confirmed that it set the path correctly in Terminal
echo $ANDROID_NDK_HOME
But when I run a shell file in a Android Studio project which invokes ndk-build I get the following error
ndk-build: command not found
How to make sure that ndk-build is in your build path ?
How to set ndk-build in my build path ?
Thanks for any help
Well, this is actually not enough to make the system aware of the path. You must add this path to the PATH system variable. In your case, all you have to do is to add the following line to your terminal configuration file (which should be under your home directory, named .bashrc if you kept the default terminal, full path: ~/.bashrc):
export PATH=$PATH:/Users/Shajilshocker/Documents/Android/NDK/android-ndk-r10b
What this line does is actually adding the path to your Android NDK directory to the PATH variable. You export a variable named PATH with its current content plus the directory of your NDK.
Step by step:
Go in the home directory
Edit .bashrc
Add the line I showed above
Save, exit, then restart bash (you just have to type bash, then enter)
For mac use this: Open your .bash_profile file with a text editor. .bash_profile is by default found in home directory. Eg /Users/john
the assumption is: you have downloaded the android sdk and ndk to /User/john/Android or you can find the path from Android Studio by going to
Project Structure > SDK Location, pay attention to Android SDK location & Android NDK location
export ANDROID_SDK=/Users/john/Android/sdk
export ANDROID_NDK=/Users/john/Android/sdk/ndk-bundle
export PATH="$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools:$ANDROID_NDK"
Then save the above lines to your .bash_profile file. Close it and try typing this on your terminal
ndk-build
if the response is like below, you are good to go
Android NDK: Could not find application project directory !
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
/Users/john/Android/sdk/ndk-bundle/build/core/build-local.mk:143: *** Android NDK: Aborting . Stop.
The assumption here is you have downloaded your android sdk to /Users/john/Android
In case this helps anyone, I installed the Android NDK using Android Studio on MacOS by following the instructions on the android.com NDK webpage: I selected Tools --> Android --> SDK Manager and then selected NDK. Android Studio then installed the downloaded files under:
/Users/user.name/Library/Android/sdk/
That directory is the same one that is listed on the SDK Manager window inside Android Studio. Underneath that directory is another directory ndk-bundle, which has all the NDK tools.
Thus, I added this to my path:
/Users/user.name/Library/Android/sdk/ndk-bundle/
cd to path you have to set.
Enter in Terminal: echo "export PATH=$PATH:$ANDROID_NDK_HOME" | sudo tee -a /etc/profile

Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions

I am MAC OS X Yosemite I have done all the export tutorial to set the android_home but non of it working for me
Making sure ANDROID_HOME is exported and adding the SDK tool directories to PATH should be more than enough to get you going.
Using the terminal
# First, we make sure we have a newline at the end of the .bash_profile
echo >> /Users/abdi/.bash_profile
# We set the ANDROID_HOME value in the .bash_profile
echo "export ANDROID_HOME=/Users/abdi/adt/sdk" >> /Users/abdi/.bash_profile
# We alter the PATH value a bit as well
echo "export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools" >> /Users/abdi/.bash_profile
# We then tell the terminal to update all the things
. /Users/abdi/.bash_profile
Using a GUI (mostly)
You can also open the .bash_profile file in TextEdit using the open -e /Users/abdi/.bash_profile command. If you get some errors about missing files, try running touch /Users/abdi/.bash_profile and retry the open command. In the file that opens, add the following lines at the end.
export ANDROID_HOME=/Users/abdi/adt/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Running . /Users/abdi/.bash_profile as in the terminal version after that should get you fully set up.
First need to set the ANDROID_HOME directory
look into your android-sdk-linux(mac) directory and look for 'android' executable file, generally it will exists under 'tools' directory
so edit your .bashrc from home folder
and add this line down there
export ANDROID_HOME=~/android-sdk-linux
PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Once done, exit your console and run your command again
You could expect an error saying " Please install Android target "android-19" " if it is not set yet.
you may fix that running "android" command and selecting "Android 4.4.2 API 19" to install.
And afterwards, don't forget to give ample permission to directory where the application resides.
I had the same problem. Luckily it is easily fixable. Just follow the next few steps (Command-line from terminal).
Open the bash_profile file using command line arguments with -
vi ~/.bash_profile
OR
It is possible to open bash_profile in TextEdit and make changes there. Use the following command to do this -
open -a "TextEdit" .bash_profile
Check if ANDROID_HOME has been set in this file. If it has been already set, delete it (probably wrong). Also check if PATH in this file has any reference to tools or platform-tools (of the android sdk). You'd be better off deleting these before you start typing the following commands.
Set ANDROID_HOME correctly using the following command
export ANDROID_HOME=/Users/adarsh/android-sdk-macosx
^this is my command because I installed it in that location. Please replace "adarsh" with your username and "android-sdk-manager" with the name of your android sdk folder that you downloaded. Do not copy-paste this command.
For example, if your username is "John" and you the android sdk folder you downloaded and installed is in "Downloads" and you changed your folder name to "sdk", then your command would be -
export ANDROID_HOME=/Users/John/Downloads/sdk
Set PATH with the following command
export PATH=$ANDROID_HOME/tools:$PATH
Refresh your bash_profile to set all the changes we just made by typing the command
source ~/.bash_profile
You should be good to go now and begin developing with ionic!Hope this helps. Cheers.
One source of this problem comes from sudo. If you're sure you've set $ANDROID_HOME correctly then try the following:
sudo visudo
then add
Defaults env_keep += "ANDROID_HOME"
Make sure the env variable you exported is ANDROID_HOME and not android_home (case sensitive).
After you export, test it by typing
> echo $ANDROID_HOME
The result should point to the dir where you installed the SDK.
Last but not least edit your /etc/paths to add dirs $ANDROID_HOME/platform-tools or /Users/abdi/adt/sdk/platform-tools and $ANDROID_HOME/tools or /Users/abdi/adt/sdk/tools to the list. Save file. You might need to edit this file as admin if need be. Close terminal and then Open new terminal. Then type
> echo $PATH
to check if the path is updated.
And then voila, when you type
> which android
you should see the correct path to the binary returned which in your case is /Users/abdi/adt/sdk/tools/android. you should be all set now.
None of the solutions here solved my problem completely. My Node version was little bit old and ionic was giving a warning to upgrade node. After upgrading Node, I had to delete the project and again create the project, then perform all the steps. Hope this helps somebody.

ERROR: 32-bit Linux Android emulator binaries are DEPRECATED

I installed the latest version of the ADT Bundle 32 bit on my ubuntu 14.04 32 bit. I created an AVD, but it doesn't launch. When I press the start button it shows this message:
Starting emulator for AVD 'NexusOne'
ERROR: 32-bit Linux Android emulator binaries are DEPRECATED, to use them
you will have to do at least one of the following:
- Use the '-force-32bit' option when invoking 'emulator'.
- Set ANDROID_EMULATOR_FORCE_32BIT to 'true' in your environment.
Either one will allow you to use the 32-bit binaries, but please be
aware that these will disappear in a future Android SDK release.
Consider moving to a 64-bit Linux system before that happens.
I tried to fix it by setting export ANDROID_EMULATOR_FORCE_32BIT=true to gedit .profile file and to gedit .bashrc file. Nothing changed.
Thank you for trying to help me!
i have one great solution.
you can start it with eclipse or netbeans.
try :
In Eclipse, click your Android project folder and then select Run > Run Configurations...
In the left panel of the Run Configurations dialog, select your Android project run configuration or create a new configuration.
Click the Target tab.
In the Additional Emulator Command Line Options field, enter:
-force-32bit
Run your Android project using this run configuration.
in netbeans you :
1. wher you choose debuger chose Customize...
in Emulator options write
-force-32bit
click ok. and run application
I solve this problem with the following:
export ANDROID_EMULATOR_FORCE_32BIT=true
Then I start the emulator from the command line. It works!
Hope it's helpful to you.
I did the following
go to the run configuration >target tab> scroll down to the last> Additional emulator command line options>-force-32bit
solution to this problem is given here
Open terminal in ubuntu, and then type gedit .profile
paste this text: export ANDROID_EMULATOR_FORCE_32BIT=true
refresh source i.e. in terminal type source .profile
When no effect, finishing that by restart your device (laptop,pc)
For Android Studio:
Run > Edit Configurations > Android > Android Application > app > Emulator tab
Enable the checkbox next to Additional command line options:
Enter -force-32bit
go to the run configuration >target tab> scroll down to the last> Additional emulator command line options>-force-32bit
I had same problem and now I solved,I have Ubuntu 15.10 And my solution was:
Open terminal
Locate path directory Android-studio at terminal
I wrote export ANDROID_EMULATOR_FORCE_32BIT=true, keyboard key enter
And execute the ./studio.sh locate in folder bin of Android-studio
ON LINUX MINT
Go to terminal
type gedit .profile
paste the below line at end of the page
export ANDROID_EMULATOR_FORCE_32BIT=true
type source .profile in terminal or restart system
ON UBUNTU
Go to terminal
type gedit .bashrc
paste the below line at end of that file
export ANDROID_EMULATOR_FORCE_32BIT=true
type source ~/.bashrc in terminal or restart system
create a shell script :
#!/bin/bash
#
# set export ANDROID_EMULATOR_FORCE_32BIT=true
export ANDROID_EMULATOR_FORCE_32BIT=true
/opt/adt-bundle-linux-x86-20140702/eclipse/eclipse
change the shell script executable and run it to active eclipse
"/opt/adt-bundle-linux-x86-20140702/eclipse/eclipse" is the path of eclipse

How do i run the Android command line tools?

I'm still pretty new to Android and programming in general, and I can't seem to get the command line tools packaged with the Android SDK to work. I'm running Mac OSX and each time I try to run layoutopt, for example, the terminal returns, *-bash: cmd: command not found
*
Also, is it okay to have my SDK located in the Developer directory and my android project in some unrelated directory when using these tools?
If you want you can put the path in your ~/.bash_profile so you can call it from anywhere:
export ANDROID_HOME=/Users/<username>/path/to/sdk/tools
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
You may want to include also the platform-tools into your ~./bash_profile
### Android dev tools
export ANDROID_HOME="/Users/myusername/DEV/tools/adt-bundle-mac-x86_64/sdk"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
You will need to start a new terminal session or run
source ~/.bash_profile
to loads the values immediately without having to open a new terminal session.
The current (2016-08-17) answer to this question is:
~/Library/Android/sdk
So my bash_profile contains:
export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
I figured it out. I needed to go to the /tools directory in the SDK folder and type in:
./layoutopt <directorypath>
Problem is your command line tool is not seeing required programs from /path/to/sdk/tools.
One solution as user NKijak mentioned is to add those tools to your Home path and the other is to run command line from location where your sdk tools are stored. Here is a tutorial how to do just that http://hathaway.cc/2008/06/how-to-edit-your-path-environment-variables-on-mac-os-x/
Other way is, when opening command line just change your current dir to /path/to/sdk/tools and then run the tools. In windows you can just shift+right click in file explorer and pick open command windows here I am not sure is there equivalent on MacOS but there are some extensions you can install to add this option. Also total commander in windows has command line where you can start command line from current location there are similar programs on mac like Midnight Commander that have same option.
Here is a good description:
To connect to the console of any running emulator instance at any time, use this command:
telnet localhost <console-port>

Categories

Resources