[英]Android Device Monitor File Explorer not working with emulator running API 24+
Till Android Lollypop emulators, we can access the file explorer folders. 直到Android Lollypop模拟器,我们可以访问文件资源管理器文件夹。 If the emulator is created with marshmallow or higher, we cant access the file explorer. 如果使用marshmallow或更高版本创建模拟器,则无法访问文件资源管理器。 May be this is bug from API level 24+. 这可能是API级别24+的错误。
A temporary solution, which worked at least for my needs, was to install file manager .apk (I used Astro file manager .apk) - just drag/drop .apk to emulator window. 一个临时解决方案,至少可以满足我的需求,是安装文件管理器.apk(我使用Astro文件管理器.apk) - 只需将.apk拖放到模拟器窗口即可。 Another very useful utility - ImDisk - which let's mount sdcard .img of virtual device. 另一个非常有用的实用工具--ImDisk - 让我们安装sdcard .img的虚拟设备。 If you mount it as readonly ejectable device, you can have realtime access to virtual device file system 如果将其作为只读弹出设备挂载,则可以实时访问虚拟设备文件系统
A workaround using the adb
command line tool: 使用adb
命令行工具的变通方法:
root@mypc ~ $ adb kill-server
root@mypc ~ $ adb start-server
root@mypc ~ $ adb root
Now you can browse through the file system using the linux ls
command: 现在,您可以使用linux ls
命令浏览文件系统:
root@mypc ~ $ adb shell ls -all /
total 3688
drwxr-xr-x 15 root root 0 2017-04-21 11:11 .
drwxr-xr-x 15 root root 0 2017-04-21 11:11 ..
drwxr-xr-x 29 root root 0 2017-04-21 11:11 acct
drwxrwx--- 6 system cache 4096 2017-01-06 12:11 cache
lrwxrwxrwx 1 root root 13 1970-01-01 01:00 charger -> /sbin/healthd
...
-rw-r--r-- 1 root root 4853 1970-01-01 01:00 ueventd.rc
lrwxrwxrwx 1 root root 14 1970-01-01 01:00 vendor -> /system/vendor
Another temporary solution is to use the adb shell 另一个临时解决方案是使用adb shell
First, copy the database to the sdcard 首先,将数据库复制到SD卡
./adb shell run-as com.yourapplication cp /data/data/com.yourapplication/databases/yourFileName.db /sdcard
Then, pull the database file to your computer 然后,将数据库文件提取到您的计算机
./adb pull /sdcard/yourFileName.db /Users/yourUserName/Desktop
It probably has to do with the new Android folder permissions. 它可能与新的Android文件夹权限有关。 As posted in another answer you can use: 如在另一个答案中发布,您可以使用:
root@mypc ~ $ adb root
to gain root access to your emulator (no need to restart the adb). 获得对模拟器的root访问权限(无需重新启动adb)。 Then you can see all the folders on the device with DDMS file explorer or through the shell. 然后,您可以使用DDMS文件资源管理器或通过shell查看设备上的所有文件夹。 The other option is to wait for a new file explorer that was promised in version 2.4 of Android Studio. 另一种选择是等待Android Studio 2.4版本中承诺的新文件浏览器。
If you need to refresh the gallery after that as I did you could use: 如果您之后需要刷新画廊,我可以使用:
root@mypc ~ $ adb shell "am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///mnt/sdcard"
This will simulate mounting of a SD card which will trigger media rescan. 这将模拟SD卡的安装,这将触发媒体重新扫描。
Its an alternative way. 它是一种替代方式。
Create a bat file configure the APP_NAME, Example (com.example.com) 创建一个bat文件配置APP_NAME,示例(com.example.com)
DESTINATION_FOLDER (myProjectFiles) DESTINATION_FOLDER(myProjectFiles)
cd "C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools\"
adb shell run-as APP_NAME rm -R /sdcard/DESTINATION_FOLDER
adb shell run-as APP_NAME cp -R cache/ /sdcard/DESTINATION_FOLDER
rmdir C:\Users\USERNAME\Documents\DESTINATION_FOLDER /s /q
adb pull /sdcard/DESTINATION_FOLDER C:\Users\USERNAME\Documents\
timeout 5
After Configuring your bat file run it by double clicking . 配置您的bat文件后,双击运行它。 it will do the rest 它将完成剩下的工作
I also faced same problem in the Android Device Monitor. 我在Android设备监视器中也遇到了同样的问题。
The emulator we use is very high level like Nougat 24+, so to over come this, we have to just run emulator in level level ie, Lollipop 22 我们使用的模拟器非常高,如Nougat 24+,所以为了超越这个,我们必须在级别级别运行模拟器,即Lollipop 22
As another workaround, I use fileList()
to get all the files in the Files
folder of my app and log it to logcat: 作为另一种解决方法,我使用fileList()
来获取我的应用程序的Files
夹中的所有文件并将其记录到logcat:
String[] files = fileList();
// log files, or add a watch in the debugger...
It is also possible to get the files and directories in your cache
folder as well: 也可以在cache
文件夹中获取文件和目录:
String[] filesInCache = getCacheDir().list();
Or 要么
File[] filesInCache = getCacheDir().listFiles();
I had this problem with Api 27 (Oreo). 我在Api 27(奥利奥)遇到了这个问题。 I tried to create emulator with Lollipop but same as with Oreo. 我尝试使用Lollipop创建模拟器,但与Oreo相同。 Device monitor was empty. 设备监视器为空。
After restarting computer everything was normal. 重启电脑后一切正常。 This is solution for many problems that comes with Android Studio. 这是Android Studio附带的许多问题的解决方案。 First check this, than everything else. 首先检查一下,而不是其他一切。
Try some methods: 尝试一些方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.