简体   繁体   English

Android设备监视器文件资源管理器无法使用运行API 24+的模拟器

[英]Android Device Monitor File Explorer not working with emulator running API 24+

So, just as question states. 所以,正如问题所述。 Android device monitor is not showing anything in the File Explorer view. Android设备监视器未在“文件资源管理器”视图中显示任何内容 This is only occuring on Virtual Devices running Android API Level 24+. 这仅适用于运行Android API Level 24+的虚拟设备。

Any solution? 有解决方案吗

在此输入图像描述

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 如果将其作为只读弹出设备挂载,则可以实时访问虚拟设备文件系统

This is bug in Android Device Monitor and has been reported to google. 这是Android设备监视器中的错误,并已报告给谷歌。

According to Post this thread will be updated when the patch is released. 根据Post,这个帖子将在补丁发布时更新。

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: 尝试一些方法:

  1. Click on the triangle icon at the device window then choose "reset adb." 单击设备窗口中的三角形图标,然后选择“重置adb”。
  2. Turn off the emulator then turn it back on. 关闭模拟器,然后重新打开。
  3. You can use Genymotion, the best simulator now. 您现在可以使用Genymotion,这是最好的模拟器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Device Monitor的文件浏览器无法使用Android 7(API 24+) - Android Device Monitor's File Explorer not working with Android 7 (API 24+) 适用于Android的VS Emulator上运行API Level 24+(Hyper-V) - Running API Level 24+ on VS Emulator for Android (Hyper-V) 具有API级别24+的android模拟器上没有可用的备份传输 - No backup transports available on android emulator with api level 24+ 在下载文件夹Android N(API 24+)中打开文件 - Opening a file in downloads folder Android N(API 24+) Android Studio-Android设备监视器的文件资源管理器不起作用 - Android Studio - Android Device Monitor's File explorer not working Android:使用API​​ 24+以编程方式打开“概述/最新”屏幕 - Android: programmatically open Overview/Recents screen in API 24+ 如何从 Android API 将文件写入 SD 卡 24+ - How to write files on SD Card from Android API 24+ 带有Android API 24+的日历提供程序“未找到请求的事件” - Calendar Provider with Android API 24+ “The requested event was not found” 使用API​​ 24+上的Uri通过Intent打开文件 - Opening File via Intent using Uri on API 24+ Android Device Monitor - 清空文件资源管理器视图 - Android Device Monitor - empty File Explorer view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM