Unable to launch emulator Once I migrated from appium 1 to appium 2

HI all,

I have single appium framework which runs for android and IOS in appium 2. IOS is working fine, when i try to launch the emulator , I’m getting below error though my zsh profile I have ANDROID_HOME and ANDROID_SDK_ROOT. When i use echo$ANDROID_SDK_ROOT or echo $ANDROID_HOME it’s displaying my SDK : /Users/xxxx/Library/Android/sdk

Recently i migrated from appium1 to appium 2. After that only, it started throwing below error.Before i used to launch emulator successfully. Anybody facing this issue while migrating from appium1 to appium 2?

cause is : nullMessage is : Could not start a new session. Response code 500. Message: 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
Host info: host: 'Ixxxxx, ip: ‘2404:4408:6a52:4400:653b:fa47:c4ea:9c2%en0’
Build info: version: ‘4.8.3’, revision: ‘e5e76298c3’
System info: os.name: ‘Mac OS X’, os.arch: ‘aarch64’, os.version: ‘13.4’, java.version: ‘11.0.18’
Driver info: io.appium.java_client.android.AndroidDriver
Command: [null, newSession {capabilities=[{appium:clearSystemFiles=true, appium:appActivity=nz.co.thewarehouse.wow.boot.SplashScreenActivity, appium:allowTestPackages=true, appium:deviceName=Pixel_2_API_30, platformName=ANDROID, appium:automationName=uiautomator2, appium:app=/xxxxxxx, appium:appPackage=xxxxx}], desiredCapabilities=Capabilities {appium:allowTestPackages: true, appium:app: xx., appium:appActivity: xx., appium:appPackage: xx, appium:automationName: uiautomator2, appium:clearSystemFiles: true, appium:deviceName: Pixel_2_API_30, platformName: ANDROID}}]
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: 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
Host info: host: ‘ITM306880’, ip: ‘2404:4408:6a52:4400:653b:fa47:c4ea:9c2%en0’
Build info: version: ‘4.8.3’, revision: ‘e5e76298c3’
System info: os.name: ‘Mac OS X’, os.arch: ‘aarch64’, os.version: ‘13.4’, java.version: ‘11.0.18’
Driver info: io.appium.java_client.android.AndroidDriver

Please let me know how to resolve this?

try to add the following to your .zshrc file.

export ANDROID_HOME="/Users/****/Library/Android/sdk"

and then run source .zshrc and then close and reopen the terminal and make sure the envs are available.

I already have that. When i type echo $ANDROID_HOME it’s displaying my SDK : /Users/xxxx/Library/Android/sdk. But still getting above error.

How are you starting Appium 2 server?