47

I am using the emulator that comes with Android Studio and need to past text between my OSX Yosemite machine and an app in the emulator.

I started my emulator with emulator -avd Nexus_6_API_23

I tried long click Command-V it does not paste

I see How can I copy/pate multibyte characters on Android Emulator? and a few others like Paste text on Android Emulator but they seem related to adb and not the new emulator.

Any ideas pls?

Community
  • 1
  • 1
aginsburg
  • 1,223
  • 1
  • 12
  • 22
  • Possible duplicate of [Paste text on Android Emulator](http://stackoverflow.com/questions/3391160/paste-text-on-android-emulator) – Aaroninus Feb 23 '17 at 13:31
  • Look at this: https://stackoverflow.com/a/42678005/207552 With the right emulator version, it works by default. – bschandramohan May 30 '17 at 14:22

5 Answers5

83

Follow these steps for write copied text:

  1. Open Terminal

  2. Write command: adb devices (it will list the device currently connected)

  3. Select Textbox where you want to write text

  4. Write command: adb shell input text 'Yourtext' (make sure only one device is connected to run this command and that you can also use Single Quotes)

  5. Done!

Parth
  • 1,908
  • 1
  • 19
  • 37
  • 5
    great answer, but, to make any use of #2 use it with -s parameter if you have multiple devices. like `adb -s {device_id} shell input text "blahblah"` Also I found that for some reason if your text contain '&' shell will try to execute it, and will fail – Max Ch Sep 23 '16 at 22:04
  • I was trying to copy-paste my account pwd into the emulator. I'm sure this solution works for most cases, but since it requires single quotes, in my case the command gets confused and dies tragically with `/system/bin/sh: no closing quote` due to special chars in my pwd -_- – radu_m Nov 30 '17 at 09:01
7

In a terminal, type

adb shell input text 'my string here.'

This work only you have one emulator or one device connected your PC.

Ahmad Aghazadeh
  • 16,571
  • 12
  • 101
  • 98
0

I had the same problem - need to copy text from macOS to a Android Virtual Device (AVD) in Android Studio. I tried the sms or telnet solutions, they worked but not really well for a large sum of text (e.g. a whole page of text with spaces, line feeds and all kinds of special characters).

Thanks to someone who created an Apple script to force input password into the password field when opening an encrypted volume. That amazing script also solved this problem! And its more straight forward in utilizing this script to copy and paste from Mac to an AVD.

I have the Apple script icon always stay on top of the screen (the status bar) so whenever I need to copy and paste, it is just one click away.

Here is a copy of the script (whoever created this, thank you again!)

——————

set numbers_key_codes to {82, 83, 84, 85, 86, 87, 88, 89, 91, 92}

set input to do shell script "pbpaste"

if (input is not missing value) then

tell application "System Events"

    repeat with char in the characters of input

        try

            key code numbers_key_codes's item (char + 1)

        on error

            keystroke char

        end try

    end repeat

end tell

end if

——————

Just copy the source text, click on the target location in the AVD, and then activate the script by clicking on the script icon, voilà, everything will be pasted like typing automatically!

Be warned that if there’s a huge sum of characters you are copying and pasting, it may take a few seconds for the script to complete the ‘typing’.

PWA
  • 1
  • 2
0

There is a tool to execute a command in the adb console to paste when ctrl + v is tapped. Try it out :)

https://github.com/HknCore/AndroidPaster/releases/tag/1.0.0

HknCore
  • 143
  • 15
-1

This feature is just not implemented. You can create a feature request from the emulator's help page

MT-Wizard
  • 158
  • 5