I have a rooted HTC device, and I want to access the /data/app/ directory on my phone to fix a bug, and I am looking for a way to do this from my PC rather than creating a new emulated environment just to fix that bug. It lead to a looping lock screen, where every three seconds I would end up at the lock screen.
If you have USB debugging enabled, you can try to open "adb shell" and inside of it get root permissions using "su" command. After that you can open any file in any folder through this shell window. Moving in between folders the same as in a Linux, and it's easy to Google how to do that.
I'm working on an app to enable people to upload photos from their phone, and I need to be able to test this functionality out in the AVD via emulator. However the AVDs don't seem to have any photos in storage so I can't use them for testing.
Is there an efficient way to get photos onto the virtual device and preferably keep them there so I can run multiple tests on them? I know I can debug on my phone as well (and have been doing that), however I would prefer to do most of my debugging on the emulator if possible.
I'm using the IntelliJ IDEA for development.
One way would be to open cmd window and type adb shell. You can then create a folder for the images you'd like in the sdcard folder. Then you can exit the shell and push the images to the device using adb push cmd.
It's pretty simple actually.
adb shell
cd sdcard
md directoryName
exit
adb push /sdcard/directoryName /pathToImage
I solved the issue by starting the Android Device Monitor in IntelliJ (Tools>Android>Android Device Monitor), navigating to the File Explorer tab, and copying pictures over to the sdcard>Downloads folder. In the device emulator, I selected 'show SD card' before I was able to use the pictures from that folder. It will probably be easier if I can find out how to put the pics on a device folder instead of SD card, but for now this suffices.
Thanks for the suggestion eclipse, helped me go down the right path.
We have to set up a number of android devices for a project we are working on... What we have to do is actually edit the iptables of the device. Rather then doing each one by one I'm curious if there is a way to set up one device then clone the image so that we have an exact replica of that image?
We would then perhaps use PhonixCard to reinstall that image on all of the other devices...
Not sure it matters much but the device is running 4.0.1... all of the devices that we want to replicate the image on are exactly the same device.
from a previous SO answer:
Make a nandroid backup from recovery.
Make sure that the backup is located on the sdcard.
Mount the sdcard on a computer and copy it's contents to a folder on a pc.
Copy the entire contents of the folder you made above to the target device.
Root the device than install a custom recovery if you didn't do this already.
In recovery restore the nandroid backup.
Reboot the device. Now everything should be exactly the same as on the original.
Repeat steps 4-7 for every device.
If there're lots of small files that need to be transferred, another possibility is zip them up copy to the phone and than unzip it using
adb shell unzip path/to/file.zip
Once the command is launched you can disconnect the device the process will continue as long as there're no conflicting files or folders.
So answer cloning android OS images
I recently bought a new phone (Motorola Electrify) and I'm trying to connect it with ADB but so far without luck. What I did:
Enable USB debugging on the phone
Connect phone to my iMac using the USB cable (the display indicates that it's connected)
Type "./adb devices" to list connected devices
Unfortunately nothing shows up. I even did a adb kill/start-server and I also added "0x22B8" to the adb_usb.ini (even though that shouldn't be necessary).
Can anyone point out what other steps I could take to debug why the device isn't showing up?
Thanks!
Thanks for your answers above, but I've resolved it myself. For anyone who has the same problem:
http://code.google.com/p/android/issues/detail?id=15583
has the answer.
It turns out that Motorola has several USB modes. I changed the mode to "USB Mass Storage" and it's working now. I did this by dragging the status bar down and clicking on "USB connection" to manage the USB connection.
In case anyone else isn't clear, usb debugging must be enabled (at least for a droid mini).
#Joris If you're loading multiple apps on your phone, you might be better off using the MTP mode on your phone (instead of USB Mass Storage) for reasons covered herein - http://www.androidcentral.com/ics-feature-mtp-what-it-why-use-it-and-how-set-it.
p.s: admittedly, this may not be backwards compatible, but hopefully everyone's finally upgrading to ICS and beyond
Step four found at this link may be helpful:
http://esausilva.com/2010/10/02/how-to-set-up-adb-android-debug-bridge-in-mac-osx/
Create an environment variable (Optional)
Open Terminal
Type cd ~ this will take you to your home directory
Type touch .profile this will create a hidden file named profile
Type open -e .profile this will open the file you just created in
TextEdit In the file, type export
PATH=${PATH}:/pathToTheAndroidSdkFolder/android-sdk-mac_86/platform-tools
Save file, close TextEdit, Quit Terminal, and Relaunch Terminal
NOTE: By creating an environment variable you won’t need to cd to the
Android/tools folder every time you want to run ADB
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)
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.
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
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.
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.
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.
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
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'
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
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
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!
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
An easy way is there
Activate keyboard in emulator.
Click on the place you want to paste and long press (press until you see the word PASTE)
Done.
See original answer: https://www.quora.com/How-do-I-paste-text-from-my-computer-to-Android-emulator
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
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
Just click the left mouse button for 2 or 3 seconds, paste button will be appear. Click the paste button and the test will be copied smoothly.
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.
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.
Using Visual Studio Emulator, Here's my method.
First Mound a virtual sd card:
Use the Additional Tools (small >> icon) for the emulator and go to
the SD Card tab.
Select a folder on your computer to sync with the
virtual SD card.
Pull from SD card, which will create a folder structure on the selected folder.
Set up a text file to transfer text:
Use Google Play Store to install a text editor of your choice
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.
Edit the text file created above.
Go to Additional Tools (small >> icon) and chose Push To SD Card.
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.
(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!
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!
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.
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.
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
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