Installing Appium Get Error - Target id is not valid. Use 'android list targets' to get the target ids

Hi All,
While installing appium, I encountered error Target id is not valid. Use ‘android list targets’ to get the target ids.. Can someone help me to fix this error? I just started learning appium.
Thanks for your help.

Steps:

  1. Type git clone https://github.com/appium/appium.git in mac terminal
  2. Type ./reset.sh in mac terminal

Actual Results:
RESETTING ANDROID

  • Configuring Android bootstrap
    Running “configAndroidBootstrap” task
    Error: Target id is not valid. Use ‘android list targets’ to get the target ids.
    Warning: Setup cmd /Users/mac/Documents/android-sdk-macosx/tools/android failed with code 1 Use --force to continue.
    Aborted due to warnings.
    ---- FAILURE: reset.sh exited with status 1 ----

The path /Users/mac/Documents/android-sdk-macosx/tools/android has no android folder but an android executable.
I typed android list targets and it lists the following two targets:
Available Android targets:

id: 1 or “android-23”
Name: Android 6.0
Type: Platform
API level: 23
Revision: 1
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
Tag/ABIs : android-tv/armeabi-v7a, android-tv/x86, default/armeabi-v7a, default/x86, default/x86_64

id: 2 or “Google Inc.:Google APIs:23”
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 1
Description: Android + Google APIs
Based on Android 6.0 (API level 23)
Libraries:

  • com.android.future.usb.accessory (usb.jar)
    API for USB Accessories
  • com.google.android.media.effects (effects.jar)
    Collection of video effects
  • com.google.android.maps (maps.jar)
    API for Google Maps
    Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
    Tag/ABIs : google_apis/armeabi-v7a, google_apis/x86, google_apis/x86_64

can you check your ANDROID_HOME details on the bash profile and can you run the Appium doctor, post the result here?

Here’s the results:

$ echo $ANDROID_HOME
/Users/vnvdm/Documents/android-sdk-macosx

$ appium-doctor
-bash: appium-doctor: command not found

I previously uninstalled the old appium 1.4.10 version via the terminal.
Then I attempted to install the appium 1.4.11 version. Before in 1.4.10, the appium-doctor command worked. But now it doesn’t work since I’m halfway installing appium when I got this error.

Thanks for helping me.

Post the appium-doctor results when it is ready.

Hi Sruthi,
I don’t know how to get appium-doctor ready. I was trying to install 1.4.11 appium, but I encountered the above android error. So I can’t install appium 1.4.11 properly so there’s no appium-doctor since appium is having trouble to install right now.
Is there something I can do to fix it?
Thanks.

Hi Sruthi,
Ok I figured out a way to run appium doctor. I ran the appium doctor from my appium GUI app 1.4.8 and it showed these results in the mac terminal. I still can’t run appium-doctor command via the terminal though.
Thanks.

unknown20C9D0E03E3B:~ mac$ ‘/Applications/Appium.app/Contents/Resources/node/bin/node’ ‘/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium-doctor.js’
Running iOS Checks
:heavy_check_mark: Xcode is installed at /Applications/Xcode.app/Contents/Developer
:heavy_check_mark: Xcode Command Line Tools are installed.
:heavy_check_mark: DevToolsSecurity is enabled.
:heavy_check_mark: The Authorization DB is set up properly.
:heavy_check_mark: Node binary found at /usr/local/bin/node
:heavy_check_mark: iOS Checks were successful.

Running Android Checks
:heavy_check_mark: ANDROID_HOME is set to “/Users/mac/Documents/android-sdk-macosx”
:heavy_check_mark: JAVA_HOME is set to “/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home.”
:heavy_check_mark: ADB exists at /Users/mac/Documents/android-sdk-macosx/platform-tools/adb
:heavy_check_mark: Android exists at /Users/mac/Documents/android-sdk-macosx/tools/android
:heavy_check_mark: Emulator exists at /Users/macDocuments/android-sdk-macosx/tools/emulator
:heavy_check_mark: Android Checks were successful.

:heavy_check_mark: All Checks were successful

Hi Sruthi,
Do you think I can install appium 1.4.11 using the appium version manager https://www.npmjs.com/package/appium-version-manager?
Would I encounter the same error? Or would it duplicate my efforts from cloning git and using reset.sh? Will it corrupt my files or mess up the installation doing duplicate ways?
I know the appium-version-manager detected the latest version as 1.4.11 and can install it.
But I’m not sure will it also give me the same target id invalid error. My goal is to update my Appium GUI app to 1.4.11 when I was initially following your instructions from the other thread, but I’m struggling to install Appium 1.4.11. I tried googling for answers and all I can see is people seeing this issue too, but I can’t find a solution from the web.
Thanks for your help.

The reset.sh method didn’t work for me and I keep encountering the target id error.
So I used another way to install version 1.4.11 using the instructions below.
Thanks Sruthi for telling me how to sync up the GUI app with the install from the command line.

Instructions to uninstall old appium version and install new appium version

  1. Uninstall old version first by npm uninstall -g appium
  2. Install by npm install –g [email protected]
  3. Run appium –v when done to check correct version is installed
  4. Run appium-doctor to make sure everything is good
  5. Open Appium GUI App
  6. Select “Developer settings” and enable it.
  7. Select Use External NodeJS Binary to /usr/local/bin/node
  8. Select Use External Appium Package to /usr/local/lib/node_modules/appium
  9. Start the Appium Server.

Had to uninstall from previous method because the SafariLauncher.zip wasn’t there with the above method. So I used the below steps and got 1.4.11 installed. The key is to use --ios and I added --real-safari

  1. Run npm view appium versions to see what is the latest version
  2. Uninstall old version first by npm uninstall -g appium
  3. Type git clone https://github.com/appium/appium.git
  4. Go to appium folder cd appium
  5. Type ./reset.sh --ios --real-safari –verbose
  6. Open Appium GUI App
  7. Select “Developer settings” and enable it.
  8. Select Use External NodeJS Binary to /usr/local/bin/node
  9. Select Use External Appium Package to /Users/mac/appium
  10. Start the Appium Server.