Android+Eclipse:无法将文件推送到 SD 卡
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6415511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android+Eclipse: Can't push files to SD Card
提问by RedLeader
Trying to push files to sd card via eclipse.
尝试通过 eclipse 将文件推送到 SD 卡。
When I pull up my DDMS view, I have 3 main directories on the device:
当我打开 DDMS 视图时,设备上有 3 个主要目录:
/data
/mnt
/system
The only SDcard folder is located at /mnt/sdcard
and it has permissions d--------
.
唯一的 SDcard 文件夹位于/mnt/sdcard
并且具有权限d--------
。
I can't push anything to it, with the error:
我无法向它推送任何内容,并出现错误:
Failed to push selection: Read-only file system
推送选择失败:只读文件系统
I had deleted and remade the device many times, with many different SD Card sized. I've tried adb remount at the adb shell as well as chmod 777
on the folder.
我已经多次删除并重新制作了该设备,其中包含许多不同大小的 SD 卡。我试过 adb remount 在 adb shell 以及chmod 777
文件夹上。
Why is this so difficult? Please help if you can.
为什么这如此困难?如果可以的话请帮忙。
rootfs / rootfs ro 0 0 tmpfs /dev tmpfs rw,nosuid,mode=755 0 0
devpts /dev/pts devpts rw,mode=600 0 0 proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0 none /acct cgroup rw,cpuacct 0 0
tmpfs /mnt/asec tmpfs rw,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,mode=755,gid=1000 0 0
none /dev/cpuctl cgroup rw,cpu 0 0
/dev/block/mtdblock0 /system yaffs2 ro 0 0
/dev/block/mtdblock1 /data yaffs2 rw,nosuid,nodev 0 0
/dev/block/mtdblock2 /cache yaffs2 rw,nosuid,nodev 0 0
回答by kord
I had the same problem, and it seems that it's impossible to mount sdcard on emulator using API Level 10. I don't know if it's an android-sdk problem or Eclipse problem, but that's it. It's possible to mount sdcard on emulators with API 7(2.1), 8(2.2) and 15(4.0.3). By the way, mounting sdcard on API 7,8,15 is a bit buggy too. I had to launch each emulator 3 times before I managed to mount sdcard: 1st and 2nd launch - not mounted, 3rd launch - mounted!
我遇到了同样的问题,似乎无法使用 API Level 10 在模拟器上挂载 sdcard。我不知道这是 android-sdk 问题还是 Eclipse 问题,但就是这样。可以在具有 API 7(2.1)、8(2.2) 和 15(4.0.3) 的模拟器上安装 sdcard。顺便说一句,在 API 7、8、15 上安装 sdcard 也有点问题。在我设法安装 SD 卡之前,我必须启动每个模拟器 3 次:第 1 次和第 2 次启动 - 未安装,第 3 次启动 - 已安装!
回答by user2288174
make sure that you pushing the file to your emulator from the left menu (devices) list in DDMB and not to your actually physical device.
确保您将文件从 DDMB 中的左侧菜单(设备)列表推送到您的模拟器,而不是您的实际物理设备。
回答by Mahm00d
I had the exact same problem and did 2 things that solved it (I don't know exactly which one did it!):
我遇到了完全相同的问题并做了两件事解决了它(我不知道究竟是哪一个做到了!):
1)In DDMS view, click on the little arrow on the top right of the devices window and click reset adb
:
1)在 DDMS 视图中,单击设备窗口右上角的小箭头,然后单击reset adb
:
2)Do the instructions provided by the accepted answer to this question:
2)执行此问题的已接受答案提供的说明:
Problem Pushing Large File to Emulator/SDcard with Eclipse DDMS
使用 Eclipse DDMS 将大文件推送到模拟器/SD 卡的问题
I highly suspect the second one did it. But I'm not sure.
我非常怀疑第二个做到了。但我不确定。
Hope it helps.
希望能帮助到你。
回答by PPerez
Your device is most likely in "USB Mass Storage" mode and will not let you access the SDCard file system from Eclipse or adb. To fix this, set the USB mode to "Charge Only" or, in some cases, "PC Mode" might work. Depending on your device, you can usually configure this mode by dragging down the notification bar at the top of the screen and clicking on "USB Connection".
您的设备很可能处于“USB 大容量存储”模式,并且不允许您从 Eclipse 或 adb 访问 SDCard 文件系统。要解决此问题,请将 USB 模式设置为“仅充电”,或者在某些情况下,“PC 模式”可能会起作用。根据您的设备,您通常可以通过向下拖动屏幕顶部的通知栏并单击“USB 连接”来配置此模式。
回答by Ravi
If you are using eclipse Window > AVD Manager > [Select your device] > Edit
如果您使用的是 Eclipse Window > AVD Manager > [Select your device] > Edit
SD Card: Enter some value Eg:512 MiB
SD 卡:输入一些值,例如:512 MiB
Should work
应该管用
回答by Chaitanya
In the above post the list of mounts have been shown, in which no mount to sdcard is there. In the DDMS the list of permissions for sdcard is shown as d-------- Anyways, the problem for me was solved once I deleted the emulator and created new one.
在上面的帖子中,显示了安装列表,其中没有安装到 sdcard 的位置。在 DDMS 中,sdcard 的权限列表显示为 d-------- 无论如何,一旦我删除了模拟器并创建了新模拟器,我的问题就解决了。
回答by grv_9098
I hope you know this and done this too.... you will need to give your app the correct permission to write to the SD Card by adding the line below to your Manifest:
我希望你知道这一点并且也这样做了......你需要通过在你的清单中添加以下行来授予你的应用正确的写入 SD 卡的权限:
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"