Could not find aapt with appium server - android

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.

Related

Nativescript command run

I have installed Android-SDK in my ARC Linux system.
but when run command 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.
Please help.
Thanks.
Add ANDROID_HOME and PATH in .profile file in $HOME directory as :
export ANDROID_HOME="path/to/android-sdk" export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Then try add android as :
tns platform add android
For any doubt refer here : https://github.com/NativeScript/nativescript-cli/issues/1097
This is the original post in NativeScript Github page

Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually

This is a comment Problem with ionic in ubuntu,The solution is to add the Android home to the path
But my problem is that Even the ANDROID_HOME is already in the PATH and When i Type
$ Android
In The terminal its open Android SDK
Why ionic Can not find The android Home?!!
Update
After adding android home to the path in this terminal session
The output of echo $ANDROID_HOME is the path to android Sdk
But Still accrue the same error?!
Your global PATH relies in /etc/environment so if you edit it here it should be also available in ionic.
After you edit it you can reloaded by executing:
source /etc/environment
If you are creating a ~/.profile or ~/.bash_profile in your user's home dir that will only be loaded in a shell environment.
Make sure that your /etc/environment file looks something like this:
ANDROID_HOME=/home/eics/Android/Sdk
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbi‌​n:/bin:/usr/games:/u‌​sr/local/games:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools”
The error is very clear and as you wrote in the comments
echo $ANDROID_HOME
yields an empty result.
In Ubuntu, to set an environment variable globally you edit /etc/environment and there you would add
ANDROID_HOME=/path/to/android/sdk
Where you actually provide a real path, after you have done that you might need to do source /etc/environment to make it work in your current session.
If you only want to do it for your terminal, you can edit ~/.bashrc instead and add
export $ANDROID_HOME=/path/to/android/sdk
After 4 days of searching And Tried so many methods to fix this problem
I fix it with theses instructions
Install node with nvm
Never user root to install node or npm
Now its works fine for my and ionic ca see Android SDK home
export/set $Android to ANDROID_HOME to your environment variables

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: 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.

IntelliJ IDEA with SBT: ANDROID_HOME not found

I'm trying to run a Android project on IntellyJ IDEA with SBT. However it fails with "[error] set ANDROID_HOME ...". Of cause I have setup ANDROID_HOME and I'm able to build and run the project from command line with sbt. Why does IntellyJ IDEA can't find it?
You should run run IDEA from the same terminal window in which you've set ANDROID_HOME environment vaiable. For example in Linux/Mac terminal:
export ANDROID_HOME=/path/to/android-sdk
cd /path/to/intelijIdea/bin
./idea.sh
If you want to set ANDROID_HOME environment variable system-wide, and not repeat this process each time you run IDEA, in Linux you should add
export ANDROID_HOME=/path/to/android-sdk
to end of ~/.bashrc file. You can do this from terminal:
printf "\nexport ANDROID_HOME=/path/to/android-sdk" >> ~/.bashrc
$ANDROID_HOME will be available after log out and back in, or run source ~/.bashrc to make it available in current shell immediately.
You can set "Project SDK" to some Android SDK not normal JDK, and the plugins can use correct ANDROID_HOME.

Categories

Resources