502

Is there an easy way to copy/paste (desktop's) clipboard content to EditView on Android Emulator?

(just for the sake to ease development/test)

3
  • 4
    re Joel Beckham-send SMS: > I usually send the text I want to copy as an sms message > through telnet and then copy the text from the sms message. Instead of using telnet you can use eclipse to simulate an incoming sms in the emulator: In the eclipse android tools (version 17 maybe also in older versions) open the DDMS-Perspective. Under "Emulator control"/"Telephony Actions" you can simulate an incoming sms > Once the emulator receives the message you can copy it and paste > it wherever you like.
    – k3b
    Commented Apr 6, 2012 at 10:15
  • 4
    For anyone looking at this question now; it's supported natively in Android now - just make sure you are using the latest Android Studio/Emulator as mentioned here: stackoverflow.com/a/42678005/207552 Commented May 30, 2017 at 14:19
  • 16
    Long press on the text field, and select Paste
    – onmyway133
    Commented Mar 13, 2019 at 12:05

26 Answers 26

412

In a terminal, type adb shell input text 'my string here. With some characters escaped like \$ that'

Note that an alternative method for including spaces in the text is to substitute %s for each space character.

14
  • 44
    If you are on a Mac, you can paste the contents of the clipboard even more easily: adb shell input text "pbpaste"
    – lowellk
    Commented Aug 5, 2013 at 17:55
  • 4
    ended up taking some hours today and wrote a workaround in python for the spaces issues. much easier to end bookmarklets to the stock browser now without having to create a dozen sync accounts. github.com/gcb/AdbPaste (written while a waited the emulator to load and a couple online gaming sessions ...!$%# slow emulator)
    – gcb
    Commented Aug 28, 2013 at 6:16
  • 3
    This doesn't seem to work with some UTF characters - after trying to send 'ლ\(ಠ益ಠლ\)', it just says 'Killed' or appears to succeed and nothing is typed, nor do I have anything pasteable in the emulator. The SMS method (I tried from DDMS) doesn't even seem to be working here, it displays as "?(????)" :(
    – Groxx
    Commented May 8, 2014 at 17:21
  • 2
    I too cannot send strings with spaces; I have to use %s.
    – Peter
    Commented Jul 29, 2014 at 6:28
  • 2
    @Peter and Rose, is there a way to add a new line? adb shell input text "This%sis%stext\nDoes%snot%work%here." prints "This is text\nDoes not work here.".
    – user47
    Commented Nov 30, 2015 at 5:28
234

With v25.3.x of the Android Emulator & x86 Google API Emulator system images API Level 19 (Android 4.4 - Kitkat) and higher, you can simply copy and paste from your desktop with your mouse or keyboard.

This feature was announced with Android Studio 2.3

Copy and Paste with the Android Emulator

12
  • 44
    As of January 2018 there is a known bug in the current emulator version where this occasionally stops working. As a workaround, click the "..." icon, go to Settings, and toggle the "Enable clipboard sharing" setting off and on. (Source)
    – mhsmith
    Commented Jan 11, 2018 at 18:52
  • 5
    How do you paste on a mac? Pressing Cmd brings up multi-touch. Cmd-V does nothing.
    – jcollum
    Commented Mar 8, 2018 at 1:37
  • 43
    @jcollum left click and hold on the text field you want to paste into, click 'Paste'. cmd+v won't work, neither would ctrl+v, I imagine. Commented Jun 18, 2018 at 0:51
  • 2
    Basically this sometimes just stops working for no good reason. I've tried toggling the "Enable clipboard sharing" and it didn't fix it Commented Aug 17, 2022 at 22:28
  • 11
    I did on&off 'Enable clipboard sharing' and even restarted the emulator and also the android studio. It doesn't work. And I found simple workaround. write something in your emulator and copy&paste. And then, paste into your editor. And then copy text from desktop and paste into your emulator. It works perfectly.
    – c-an
    Commented Mar 24, 2023 at 3:17
111

Just copy from wherever, click and hold on the emulator phone's edit text where you want the text to go (kind of like you would press and hold to paste on an actual phone), the PASTE option will appear, then PASTE.

2
  • 4
    Thank you! Definitely my favorite answer. With the current version of the emulator, this is very convenient. (The current emulator has a setting in the emulator controls under "Settings" which allows for clipboard sharing.) Commented Apr 5, 2018 at 15:47
  • 1
    This is how to paste on Mac, since the command key starts touch gestures by default.
    – Jim
    Commented Jun 8, 2018 at 22:11
88

I usually send the text I want to copy as an sms message through telnet and then copy the text from the sms message. Here's how:

Connect through telnet:

  • Syntax: telnet localhost <port>
  • Example: telnet localhost 5554

(5554 is the default port. The title bar of the emulator shows the port that is being used, so you can see if it's different).

Send message:

  • Syntax: sms send <senders phone number> <message>
  • Example: sms send 1231231234 This is the message you want to send

(You can just make up the senders phone number)

This works really well for links as the message is automatically converted into a hyperlink which you can click without having to copy / paste it into the browser.

Once the emulator receives the message you can copy it and paste it wherever you like.

12
  • 3
    you even don't need telnet ... you can send sms from ddms (but ddms need telnet however). But nice idea :)
    – Tima
    Commented Dec 12, 2011 at 15:05
  • Really nice idea but to be honest: no. Doesn't worth the effort for smaller text o.O
    – nuala
    Commented Mar 12, 2012 at 13:52
  • 1
    For anyone interested, just created a shell script for doing this: gist.github.com/2050770 Commented Mar 16, 2012 at 16:10
  • 8
    This answer is overkill. use adb. See my answer. Commented May 17, 2013 at 22:30
  • 1
    Overkill or not, but it allows pasting text as is, without the need to escape special characters.
    – dmitry
    Commented Sep 14, 2015 at 16:53
63

Not sure if that's useful, but, if you need a long URL from desktop browser to be opened in mobile browser, you can send SMS with that URL and open directly from message app.

enter image description here

4
  • You can even copy that text. I found this way one of the simplest and the trickiest one! Commented Feb 21, 2018 at 18:49
  • I got this error: "Cannot send the message, radio is off" (on MacBook)
    – Atetc
    Commented Apr 5, 2018 at 13:15
  • That is definetely useful! Direcly from the very same UI of the emulator, no telnet, no parameters. And the URL use case just feet my needs. A very effective solution. Commented May 1, 2018 at 11:15
  • Nice trick indeed!
    – Lucas
    Commented May 17, 2023 at 19:33
44

For Mac users, a MUCH easier way is to do this right in the android emulator:

  • click and hold for a second or two
  • release click
  • the option 'paste' will appear as follow

enter image description here

3
  • Works on Linux too, and presumably on Windows.
    – Slbox
    Commented May 5, 2022 at 23:14
  • confirmed worked on windows too
    – albanx
    Commented Jan 6, 2023 at 12:04
  • 4
    Well, it sometimes doesn't work. That's why he asekd
    – c-an
    Commented Mar 24, 2023 at 3:05
18

If you are using Android Studio on a Mac, you may need to provide the full path to the adb executable. To find this path, open:

Android Studio > Tools > Android > SDK Manager

Copy the path to the SDK location. The adb executable will be within a platform-tools directory. For me, this was the path:

~/Library/Android/sdk/platform-tools/adb

Now you can run this command:

~/Library/Android/sdk/platform-tools/adb shell input text 'thetextyouwanttopaste'
3
  • Either use a terminal alias or add ~/Library/Android/sdk/platform-tools/ to your PATH variable to make this easier to use.
    – ThomasW
    Commented Nov 13, 2020 at 2:21
  • 1
    This works for short texts, but cuts off longer ones, like for example a JWT. Commented May 11, 2022 at 12:20
  • Works only for very short text, but better than nothing. Thanks! Commented Oct 3, 2022 at 18:37
18

On Linux this will paste text directly from the clipboard

adb shell input text "'$(xclip -selection c -o)'"

Also it very useful to create global keyboard shortkey with this command for example Ctrl+Shift+Super+V

1
  • I find this usefull everytime the clipboard syncing get error and you cant make the copy paste from Mac/Linux to the Emualtor, but using this command make this work again Commented Feb 8, 2023 at 3:51
13

Just click the left mouse button and keep it down for 1 full second, then release it.
A paste button will appear. Click the paste button and the text will be copied.

2
10

I got tired of this problem so I just made this alias to handle it:

alias ap="pbpaste | xargs adb shell input text"

Then when you open a new terminal window, typing "ap" will paste whatever is on your clipboard into the emulator's actively selected text field.

Setup

Simply add this to your profile (for most users that's ~/.bash_profile for zsh users that's ~/.zshrc) to make the alias available everywhere. Alternatively, if you're a bash user (the default for MacOS), then you can run the following command in the terminal to set it up for you:

echo "alias ap='pbpaste | xargs adb shell input text'" >> ~/.bash_profile && source ~/.bash_profile
3
  • or alias ap="adb shell input text `pbpaste`"
    – gderaco
    Commented Nov 13, 2017 at 13:10
  • am using windows and alias 'alias' is not recognized as an internal or external command, operable program or batch file. what to do
    – shareef
    Commented Sep 25, 2018 at 16:16
  • @shareef This wouldn't work for you anyway because pbpaste is macOS specific, but there is probably something similar on Windows. alias also might not be available to you depending on the shell you're using.
    – ThomasW
    Commented Nov 13, 2020 at 2:23
10

Only For API level >= 24

Copy any text from your local machine and then simply run this command

adb shell input keyevent 279

Make sure In Android Emulator Settings the Enable Clipboard Sharing options is enabled

10

My case was that my emulator pasted something that I copied few days earlier and never pasted the last thing in my current clipboard of my laptop.

To solve that I made my emulator starts from cold boot rather than quick boot.

0
8

Adding another answer, since this is the only (weird) way I was able to fix this.

There's a (non-working) setting called "Enable clipboard sharing". It does not work at first:

enter image description here

However, once you enabled that setting you have to use built-in copy-paste at least once on the device, only THEN it starts working (when the Android keyboard is open, as soon as you copy something on Windows/Mac, the value becomes available on the Android keyboard for a little while).

Also keep in mind that the emulator watches the host-operating system's "copy" event and only offers the text after that.

I.e. if you've already had something in the clipbaord before opening the emulator, it won't be available, since there was no event to catch.

1
  • This did the trick for me too. Weird. Ty Commented Apr 15 at 12:24
7

maybe a little bit tricky, but you could send an sms to the emulator by using the emulator control. then you do not have to retype all the text if it is longer and can copy-paste it in the emulator.

another way: connect to emulator via "telnet localhost PORT" and then use hardware event sending to send a text input event to the emulator (needs to be UTF-8). look at this

0
7

Made this Windows application that allows users to copy paste to Android emulators or connected devices from a visual interface. https://github.com/Florin-Birgu/Android-Copy-Paste

enter image description here

2
  • Thanks for sharing!
    – Freshchris
    Commented Aug 14, 2017 at 2:10
  • 1
    Download link is not working (May 2023)
    – gpwr
    Commented May 3, 2023 at 10:15
7

You can do this without workarounds too. Just click and hold for a bit in the input field till the paste notification appears and then click on paste. That's it!

7

An easy way is there

  1. Activate keyboard in emulator.
  2. Click on the place you want to paste and long press (press until you see the word PASTE)
  3. Done.

See original answer: https://www.quora.com/How-do-I-paste-text-from-my-computer-to-Android-emulator

2

Have you looked at C2DM? chrome2phone and fox2phone can send links and clipboard text and automatically copy it on the phone. Also, try using the adb shell. There's a service command (/system/bin/service) which can use services (service call clipboard ...). The transaction codes are 1, 2, and 3, for getClipboardText, setClipboardText, and hasClipboardText respectively.

1

Using Visual Studio Emulator, Here's my method.

First Mound a virtual sd card:

  1. Use the Additional Tools (small >> icon) for the emulator and go to the SD Card tab.
  2. Select a folder on your computer to sync with the virtual SD card.
  3. Pull from SD card, which will create a folder structure on the selected folder.

Set up a text file to transfer text:

  1. Use Google Play Store to install a text editor of your choice
  2. Create a text file containing your text on you computer in the download directory of the virtual sd card directory you created before.

Whenever I need to send text to the clip board.

  1. Edit the text file created above.
  2. Go to Additional Tools (small >> icon) and chose Push To SD Card.
  3. Open the text file in the text editor I installed and copy the text to the clip board. (Hold down the mouse when the dialog opens, choose select all and then click the copy icon)

Once set up it pretty easy to repeat. The same method would be applicable to other emulators by you may need to use a different method to push your text file to emulator.

1
  • Also, the text editor I use notifies me that the content has changed and ask me if I want to reload it. Commented May 21, 2016 at 21:38
1

(converting comment discussion to answer)

only solution on windows: https://github.com/gcb/AdbPaste

wrote it in a couple hours to work around this problem. I am now back on 100% linux, so feel free to join it as a contributor or maintainer!

2
  • Thanks for this. Note to others: it's slow for sending multiple lines. I have a 3 page LUA script to upload and this solution takes like 20 minutes from a file source. Google really needs to address this need. I know of an open source Keyboard app that has a telnet interface that would be much faster, but switching the keyboard in/out becomes an extra step. Commented May 24, 2017 at 17:00
  • 1
    To solve the speed issue mentioned in my last comment: I found it's far faster to just put a tiny helper app on the device that can take clipboard content from adb broadcast command. This populates the clipboard instead of direct input as AdbPaste does - but I was able to enhance it to read a text file and for my 3 page LUA script it now takes only 1 or 2 seconds to go from adb command to having it in the Android textbox. The app is called clipper and enhanced to read text file is here: github.com/RoundSparrow/clipper Commented May 25, 2017 at 2:19
1

For Mac and Linux try this function in your aliases_bash file (located in /etc/aliases_bash for Mac folks, be sure to use sudo vim /etc/aliases_bash)

function adbtx {
  userinput="$(sed 's/ /%s/g' <<< $1)"
  adb shell input text "${userinput}";
}
export -f adbtx

Then in the command line enter:

adbtx 'Your text to emulator input'

'Your text to emulator input' will be input on the emulator text field.

Kudos to Eliot for his substitution string for sed.

1

Write command: adb devices (it will list the device currently connected) Select Textbox where you want to write text. Write command: adb shell input text "Yourtext" (make sure only one device is connected to run this command) Done!

0

I came here looking for a solution to the same problem, and ended up writing an Android application to solve this problem. You can download it at http://www.box.net/shared/6203bn441bfltkimajmk. Just give a URL via Preferences menu to point to a place where you can change the Web response easily. The first line of the Web response will be copied to your emulator's clipboard for you. More details can be found at http://agilesc.barryku.com/?p=255.

1
  • 1
    You should not post executable code here. The source code would be much better.
    – lowellk
    Commented Aug 5, 2013 at 17:57
0

Actually, in my case restarting the MacBook and running the emulator with this command fixed the issue:

 emulator -avd Pixel_5_API_31  -wipe-data

remember that you should use your emulator device, to see the emulator list use this command:

emulator -list-avds 
0

Sometimes the clipboard of the emulator is not synched with the system clipboard. It is a bug.

But you can consider the ability to change the value of a variable in debug mode: https://www.jetbrains.com/help/idea/tutorial-set-value.html#solution (Android Studio based on IntelliJ IDEA, so I hope that this link will be helpful)

If your app reads the text from clipboard, you can change the value of the variable for this text and past your text there

0

To my understanding, It's totally depends on the Emulator that you use

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