How to copy files to Android emulator instance - android

How am I able to push .txt files to the emulator using Android Studio?

One easy way is to drag and drop. It will copy files to /sdcard/Download. You can copy whole folders or multiple files. Make sure that "Enable Clipboard Sharing" is enabled. (under ...->Settings)

Update (May 2020):
Android studio have new tool called Device File Explorer. You can access it in two way:
By clicking on Device File Explorer icon in right bottom corner of android studio window.
If you could not find its icon, inside Android Studio press shift button twice. Quick search window will appear, then type Device File in it and Device File Explorer will appear in search result and you can click it.
Then you can navigate to folder which you want to push your file in it. Right click on that folder and select upload(or press Ctrl+Shift+O). Select file you want to upload and it will upload file to desired location.
Push file using adb.exe:
In Android 6.0+, you should use same process but your android application cannot access files which pushed inside SDCARD using DDMS File Explorer. It is the same if you try commands like this:
adb push myfile.txt /mnt/sdcard/myfile.txt
If you face EACCES (Permission denied) exception when you try to read file inside your application, it means you have no access to files inside external storage, since it requires a dangerous permission.
For this situation, you need to request granting access manually using new permission system in Android 6.0 and upper version. For details you can have a look in android tutorial and this link.
Solution for old android studio version:
If you want to do it using graphical interface you can follow this inside android studio menus:
Tools --> Android --> Android Device Monitor
Afterward, Android Device Monitor(DDMS) window will open and you can upload files using File Explorer. You can select an address like /mnt/sdcard and then push your file into sdcard.

You can use the ADB via a terminal to pass the file From Desktop to Emulator.
adb push <file-source-local> <file-destination-remote>
You can also copy file from emulator to Desktop
adb pull <file-source-remote> <file-destination-local>
How ever you can also use the Android Device Monitor to access files. Click on the Android Icon which can be found in the toolbar itself. It'll take few seconds to load. Once it's loaded, you can see a tab named "File Explorer". Now you can pull/push files from there.

Android Device monitor is no longer available in android studio.
If you are using android studio 3.0 and above.
Go to "Device File Explorer" which is on the bottom right of android studio.
If you have more than one device connected, select the device you want from the drop-down list on top.
mnt>sdcard is the location for SD card on the emulator.
Right click on the folder and click Upload. See the image below.
Note: You can upload folder as well not just individual files.

I am using Android Studio 3.3.
Go to View -> Tools Window -> Device File Explorer.
Or you can find it on the Bottom Right corner of the Android Studio.
If the Emulator is running, the Device File Explorer will display the File structure on Emulator Storage.
Here you can right click on a Folder and select "Upload" to place the file
I usually use mnt - sdcard - download folder.
Thanks.

After you drag and drop your files from Desktop to Emulator like this answer here :
https://stackoverflow.com/a/44885506/3904109
Your location of files will be
Android 19, 21, 22 /storage/sdcard/Download
Android 23, 24, 25, 26, 27, 28, 29, 30 /storage/emulated/0/Download

Open command prompt and give the platform-tools path of the sdk.
Eg:- C:\Android\sdk\platform-tools>
Then type 'adb push' command like below,
C:\Android\sdk\platform-tools>adb push C:\MyFiles\fileName.txt /sdcard/fileName.txt
This command push the file to the root folder of the emulator.

refer johnml1135 answer, but not fully work.
after self investigate, using official docs, it works now:
and use Drag and Drop actually worked, but use android self installed app Download, then you can NOT find the copied file, for not exist so called /sdcard/Download folder.
finally using other file manager app, like
ES File Explorer
then can see the really path is
/storage/emulated/0/Download/
which contains the copied files, like
/storage/emulated/0/Download/chenhongyu_lixiangsanxun.mp3
after drag and drop more mp3 files:

adb push [file path on your computer] [file path on your mobile]

on windows 10 , android studio emulator.
be on the directory yourFile.xml is.
on terminal, command:
adb push yourFile.xml \C:\Users\yourUN\.android\avd\Pixel_4_API_29.avd\mnt\sdcard
Pixel_4_API_29 is the emulator name , choose the device you are using on emulator

Just need to drag and drop to the corresponding directory in the ADB

Related

How to open Android Device Monitor in latest Android Studio 3.1

Recently I updated my android studio, after the update, I am unable to find android device monitor option in the tools section. In the previous update it was there in tools->android->android device monitor. But now in the updated version, it is not present. You can check screenshot of my android studio.
If you want to push or pull your files from devices monitor now android studio offers something better then android monitor. Just take a look at right side of your studio there is an option device file explorer. Open it and you are good to go. Select your device from top dropdown and rest of everything is pretty much the same as it was in android monitor. Below is the screen Shot attached to give you the exact location and idea.
Now you can use device file explorer instead of device monitor. Go to
view > tool windows > device file explorer
screenshot: opening device file explorer in android studio 3.1.3
More details
Click View > Tool Windows > Device File Explorer or click the Device File Explorer button in the tool window bar to open the Device File Explorer.
Select a device from the drop down list.
Interact with the device content in the file explorer window. Right-click on a file or directory to create a new file or directory, save the selected file or directory to your machine, upload, delete, or synchronize. Double-click a file to open it in Android Studio.
Android Studio saves files you open this way in a temporary directory outside of your project. If you make modifications to a file you opened using the Device File Explorer, and would like to save your changes back to the device, you must manually upload the modified version of the file to the device.
screenshot: The Device File Explorer tool window
When exploring a device's files, the following directories are particularly useful:
data/data/app_name/
Contains data files for your app stored on internal storage
sdcard/
Contains user files stored on external user storage (pictures, etc.)
Note: Not all files on a hardware device are visible in the Device
File Explorer. For example, in the data/data/ directory, entries
corresponding to apps on the device that are not debuggable cannot be
expanded in the Device File Explorer.
To start the standalone Device Monitor application, enter the following on the command line in the android-sdk/tools/ directory:
monitor
You can then link the tool to a connected device by selecting the device from the Devices pane. If you have trouble viewing panes or windows, select Window > Reset Perspective from the menu bar.
Note: Each device can be attached to only one debugger process at a time. So, for example, if you are using Android Studio to debug your app on a device, you need to disconnect the Android Studio debugger from the device before you attach a debugger process from the Android Device Monitor.
reference : https://developer.android.com/studio/profile/monitor.html
=> You Can change minSdkVersion 16 And open Device File Explorer
Device File Explorer work same as a Android Device Monitor
See Below Image:
From Android Studio 3.1 Device Monitor available from the command line only.
In Android Studio 3.1, the Device Monitor serves less of a role than
it previously did. In many cases, the functionality available through
the Device Monitor is now provided by new and improved tools.
See the Device Monitor documentation for instructions for invoking the
Device Monitor from the command line and for details of the tools
available through the Device Monitor.
To start the standalone Device Monitor application, enter the following on the command line in the android-sdk/tools/ directory:
monitor
To start the standalone Device Monitor application, enter the following on the command line in the android-sdk/tools/ directory:
monitor
But remember
Most of the Android Device Monitor componenets are deprecated after 3.0
For detail info visit this link
To get it to work I had to switch to Java 8 from Java 10 (In my system PATH variable) then go to
C:\Users\Alex\AppData\Local\Android\Sdk\tools\lib\monitor-x86_64 and run monitor.exe.
jdk max version is 1.8.0_144
then run monitor
As said in "Testing the game on your Android device", I followed these three steps
With the game still running on your device, return to your computer.
Navigate to the directory containing the Android SDK Tools.
Navigate to tools and double click the application called monitor.
This was prompting the following error
I've also tested using cmd and the same error persisted
To fix it, I had to go to AndroidSDKTools\tools\lib\monitor-x86_64 and double click in the monitor application
And then the Android Device Manager just started as normal
You still can run it from File explorer on Windows 10 with the proper path. You just need to go to C:\Users\user\AppData\Local\Android\Sdk\tools\lib\monitor-x86_64 and double click the file monitor.
If you want to use in the cmd just the 'monitor' command you have to add this folder (in my case with android studio 3.4.1 and win10) to your Environment variables. So, press the start button and then type Edit the system environment variabes click it and System properties window should open. Then go to
Environment variables => System variables => path
press the Edit button for path and add the new value
C:\Users\user\AppData\Local\Android\Sdk\tools\lib\monitor-x86_64
click 'Ok', 'Ok' and 'Ok' and restart the cmd window if you had it opened and type 'monitor' and it should open the monitor as well.
Hope it helps!
PD: This answer was based on this answer https://stackoverflow.com/a/55077068/5360905 from Tiago Martins Peres
ADM was deprecated in 3.1 version of android studio and removed from Android Studio 3.2. Android Device Monitor have been replaced by new features and to start Android Device Monitor application in android studio 3.1 and lower, following the commend line android-sdk/tools/ directory:
monitor
If you're looking for the Hierarchy Viewer tool, it has been changed to Layout Inspector:
https://developer.android.com/studio/debug/layout-inspector.html
Android Device Monitor was deprecated in Android Studio 3.1 and removed from Android Studio 3.2
Use Android Profiler introduced in Android Studio 3.0 to measure the cpu utilisation, network, memory etc,. To open Android Profiler: View -> Tool Windows -> Profiler.
Android Device Monitor has been replaced by some new feature which you can find here.
According to developer docs, it's deprecated now. Please follow these docs:
developer link
On Android Studio 3.1 and above, you can push photos to the emulator, by first starting the emulator. Then select “Device File Explorer” from the menu at the top of the screen: View/Tool Window/Device File Explorer
Then look in the folder titled “sdcard” and you will see a folder titled “Pictures”, click on it.
Then right click it and select “Upload” and navigate to the photo on your computer, to the photo you would like to push onto the emulator. The restart the emulator.
See photo below:
example of uploading a photo to emulator
Check this link out.
Open your terminal and type: Android_Sdk_Path/tools
Run ./monitor

Add folder/files in Genymotion emulator

I want to add folder in my Genymotion emulator
I also tried this question and follow all instruction but folder is not showing in file manager
I also download some images from Google but also those not visible in file manager.
In my emulator following file manager installed
File Managerv 1.0.1
The CyanogenMod Project
I solve my problem
First follow this Answer
Go to your VirtualBox VM setting / Shared folder tab
Add a shared folder with the folder you want to shared, and check the
"auto mount" option
Start your VM as usual from the Genymotion software
Your shared folder is available in the /mnt/shared directory
(multiple shared folders are supported)
After that
Change Settings of file Manager in Genymotion emulator change that to root user so all my folder visible also with Shared folders
In Genymotion virtual device, run the application "File Manager" and
READ the advertisement about "low-privileged mode".
Go to "settings" menu from "File Manager"
In "general settings", click on "access mode" and activate "Root
access" mode
Restart File Manager => all directories will be presented
Thanks
Update
In newer version of genymotion you can add files/folder by drag and drop.
It take some time while adding files in emulator. time depends on file size.
Update 2 (Based on #GandhyOnly comment)
To make visible in gallery just drag and drop your images files on emulator they stored in download folder after finish transferring files restart same emulator and images will shown in gallery. Or if you don't want to restart emulator then use following command
adb shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard/
it will rescan images and show them in gallery. For more detail about command see the actual answer here. I didn't check command I use first method just restart emulator
Simply drag and drop onto the emulator the file that you want to use.
It will be saved in Download folder.
I have a more simpler approach to this .
Open your genymotion , and just
drag and drop
the file in the required directory
I am attaching two screenshots in this regard.I had an app that used pictures, after copying by drag and drop i was able to find pictures in file manager through my app.
**
Just drag and drop like following
**
And you are done
It will be copied to Download Folder
Simply Drag and drop files from your PC to emulator and after copying data, files will be saved in the DOWNLOAD folder. Remember that to make DRAG and DROP service working, do not open Genemotion Software by ADMINISTRATOR privileges.
I'm not sure whether you're using SD card or not. In case you do, try to look in this folder through DDMS file explorer in Eclipse:
mnt/shell/emulated/0/MyFiles
This is where my files go when using standard SD card reference in my code:
File sdCard = Environment.getExternalStorageDirectory();
File directory = new File (sdCard.getAbsolutePath() + "/MyFiles");

Where is Android Emulator Internal Storage

I have an error due to the contents of a file stored in internal storage on my Android Emulator. (I wrote it to file). Is there a way I can view the internal storage used by my app in windows?
I've searched through my whole project folder, sdk, workspace etc and cant find anything. I saw someone in another question say it was in the /data folder, but i dont know where to look for that either.
Thanks
If you want to view the folder/file structure of the running emulator, you can do that with the Android Device Monitor which is included with the SDK.
Specifically, it has a File Explorer, which allows you to browse the folder structure on the device. It also has buttons which give you the adb push/pull functionality but from a GUI if this is easier for you to use.
In Android Studio on Mac you can go to View -> Tool Windows -> Device File Explorer. Here you can use a finder-like structure.
They are stored in an img file inside the avd directory. If you are using Linux you can mount the img file via:
sudo mount -o loop ~/.android/avd/<youremulator>/sdcard.img <mountpoint>
Not sure if there is a way in Windows or Mac to view the contents of the img since they are either in ext3, ext4, or yaffs file system format (depending on what you are emulating) and windows doesn't easily support those file systems.
Your best bet is to use adb to copy the file directly out of the emulator while it is running as shown in adb --help:
adb pull <remote> [<local>] - copy file/dir from device
In Android Studio 3.2 and later you can access a device's internal storage by using the menu item
View -> Tool Windows -> Device File Explorer
See this article for details: https://developer.android.com/studio/debug/device-file-explorer
...and this one to find out where the other components of Android Device Monitor ended up: https://developer.android.com/studio/profile/monitor
In Android N emulator you can easily get access Internal Memory.
Go to Emulator:
Settings -> Memory -> Internal Storage -> Others
Then a pop up will open. Click on explore. Then you will get access of Internal Storage.
in Android Studio 4.1 and later you can access a device's internal storage by using the menu item
View -> Tool Windows -> Device File Explorer -> storage

Location of my apk file in emulator

I wrote a small program in eclipse -android.Now i installed and i am running my program which is an .apk
Now i want to know where my .apk file is there and i even want to "pull" it into my system. Is it possible? If so kindly help me.
If you just want the apk to install on a phone or similar use File -> Export -> Android Application
Yes should be possible. Do a adb shell and look under /data/apps (e.g. ls /data/apps). Once you know the filename you can do adb pull filename .
You can run project without make apk, just right click on project >> Run as >> android application.
But if you want to find apk, it is already in workspace/your project/bin/name.apk
Yes it is possible you can also get from the ddms window into the eclipse. In the ddms select the device from the device window at left side and at right side you getting the tabbed window File Explorer, logcat, console etc.
Select File Explorer->data->app
here you getting the list of all the apk files select it and pull it by using right to top button of this File Explorer window.
see this image
ddms view
Use File Explorer within Eclipse to see all the files and folders of your emulator.

How to access local files of the filesystem in the Android emulator?

I want to know whether there is a method to access local files (say text files, web pages) of the filesystem in Android emulator.
I'm using Ubuntu 10.04 for Android development.
You can use the adb command which comes in the tools dir of the SDK:
adb shell
It will give you a command line prompt where you can browse and access the filesystem. Or you can extract the files you want:
adb pull /sdcard/the_file_you_want.txt
Also, if you use eclipse with the ADT, there's a view to browse the file system (Window->Show View->Other... and choose Android->File Explorer)
In Android Studio 3.0 and later do this:
View > Tool Windows > Device File Explorer
In addition to the accepted answer, if you are using Android Studio you can
invoke Android Device Monitor,
select the device in the Devices tab on the left,
select File Explorer tab on the right,
navigate to the file you want, and
click the Pull a file from the device button to save it to your local file system
Taken from Working with an emulator or device's file system
In Android Studio 3.5.3, the Device File Explorer can be found in View -> Tool Windows.
It can also be opened using the vertical tabs on the right-hand side of the main window.
Update!
You can access the Android filesystem via Android Device Monitor. In Android Studio go to Tools >> Android >> Android Device Monitor.
Note that you can run your app in the simulator while using the Android Device Monitor. But you cannot debug you app while using the Android Device Monitor.

Categories

Resources