I've read I can simulate a tap on my touchscreen by using adb but it doesn't work:

C:\>adb shell input touchscreen tap 1 1
Error: Unknown command: touchscreen
usage: input [text|keyevent]
       input text <string>
       input keyevent <event_code>

How come I can't send a tap to my device? I have the latest version of the SDK tools and the SDK platform tools. Android Debug Bridge version 1.0.32. Thanks

  • Open a terminal on your device and type input. What options does it show? Is your Android version beyond 4.4? – ott-- May 20 '15 at 6:59

Your version of SDK tools has nothing to do with the parameters input can understand or execute. Input is a binary in Android OS which can be run independently without requiring any set of external tools such as ADB.

The reason you receive the error "Error: Unknown command: touchscreen" is because you're running an Android version earlier than Android 4.1.1. You would already notice that in the input usage you posted, the binary entertains only two parameters i.e. text and keyevent.

In Android 4.0.x, the input command's usage remains the same as the one you posted. In fact, even Android 2.3.7 has the same input command's usage. (See com.android.commands.input.Input on GrepCode for comparison of command's usage between Android versions.)

It was Android 4.1.1 which introduced tap and swipe parameter with usage,

usage: input ...
       input text <string>
       input keyevent <key code number or name>
       input tap <x> <y>
       input swipe <x1> <y1> <x2> <y2>

See the source code for more.

| improve this answer | |

Older versions of android don't have the tap feature of the input command. I have a 4.0 device which lacks it as well.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.