how to set Environment variables for android SDK command line tools

Viewed 1303

I have tried everything i have seen online to set up my android SDK $ANDROID_HOME and $ANDROID_SDK_ROOT environment variables

but I had no luck as my Appium code shows below error each time :

Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported. Read https://developer.android.com/studio/command-line/variables for more details
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'

I'm using android command line tools: commandlinetools-linux-6609375_latest.zip

i downloaded the zip file and extracted it to /opc/android

I have tried below values in ~/.bashrc:

ANDROID_HOME=/opt/android
ANDROID_SDK_ROOT=/usr/lib/android-sdk
ANDROID_SDK_ROOT=/opt/android
ANDROID_SDK_ROOT=/opt/android/cmdline-tools/

but the same error shown above pops out

I don't know what's the problem

2 Answers

Try:

export ANDROID_HOME=$HOME/opt/android

export ANDROID_SDK_ROOT=$ANDROID_HOME

Prerequisite: Install different packages as required.

Step 1. Right-click on ‘My Computer’ and select Properties. Go to Advanced system settings and select ‘Environmental Variables’ option.

Step 2. Under the User Variable table, click New to open New User Variable dialog.

Step 3. Put ANDROID_HOME as Variable name and provide the path of the SDK folder next to Variable value.

Step 4. Click OK to close the dialog box.

Step 5. Go to the folder where SDK has been installed.

Step 6. Inside the SDK folder look for ‘tools’ and ‘platform-tools’ folder.

Step 7. Copy the path for both tools and platform-tools.

Step 8. Open ‘Environmental Variables’ dialog box.

Step 9. Go to System Variables table and locate the Path variable.

Step 10. Edit the path variable from ‘Edit system Variables’ dialog box.

Step 11. Add the ‘tools’ and platform-tools’ folder’s full path, as shown below.

Step 12. Close the entire opened dialog box.

Step 13. This configures the Android. However, to check open the command prompt.

Step 14. Type the command ‘android’. This will open the Android SDK Manager dialog box

Step 15. This ensures that the android is configured properly.

enter image description here

Related