71

I am developing under Android 1.6 (Android SDK 2.1). I create a avd by using avd manager in Eclipse. When I launch this avd, I found that the /sdcard directory's permisson is "d---------". So I can't push file to the sdcard.

Does anyone know how to solve this problem?

John Carter
  • 53,924
  • 26
  • 111
  • 144
Leox
  • 891
  • 2
  • 8
  • 8
  • Try this: http://stackoverflow.com/questions/2083709/android-emulator-sdcard-push-error-read-only-file-system/40449314#40449314 – intrepidis Nov 06 '16 at 12:41

21 Answers21

132

I found this works

$./adb shell
$su
mount -o rw,remount rootfs /
chmod 777 /mnt/sdcard
exit

Source: http://www.coderanch.com/t/611842/Android/Mobile/Android-emulator-sdcard-writable

Jay Wick
  • 12,325
  • 10
  • 54
  • 78
user2002993
  • 1,481
  • 1
  • 9
  • 9
47

Once you started the Emulator from one shell, login to another shell & type

adb shell

You should see # prompt displayed, this is your device(emulator) shell. Now , type following command at adb shell.

mount -o remount rw /sdcard

This will now remount /sdcard with rw(read-write) permission & now you can push your files into /sdcard by using following command from your host shell.

`adb push filename.mp3 /sdcard,`

where filename.mp3 could be any file that you want to push into Android Emulator.

Hope this helps :)

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
ashutosh
  • 471
  • 4
  • 3
  • Even if remount does not work, see if the link is proper. That is `/sdcard -> /mnt/sdcard`. If that is properly linked, check the permissions of the directory `/mnt/sdcard`. If necessary permissions are not there, issue the chmod command to do it. For example `# chmod 0777 /mnt/sdcard` should work. PS : You don't need the execution permission normally. – C-- Nov 28 '12 at 11:07
  • 12
    I had the same problem as @Hissain. I was able to make it work with these commands in stead: `mount -o rw,remount rootfs /` and `chmod 777 /mnt/sdcard`. Hope this helps. – TragedyStruck Jun 17 '14 at 21:21
  • su: not found ... mount: Permission denied – Marek Bernád Aug 18 '17 at 12:30
18

Ensure two things in the AVD manager utility for the emulator:

  1. SD Card size is mentioned e.g. 512.

  2. From the Hardware tag, press New and select "SD Card Support" from the drop down menu.

Now, start the emulator. SD Card shall now support writing as well.

Sumit
  • 291
  • 2
  • 2
10

Android studio version 0.8.9 and above has a bug creating AVDs.

See Issue 78434.

Workaround

  • go to your ADV folder in .android folder and find your AVD config.ini
  • open it with a text editor that can handle unix newlines. (Notepad will run the lines together since they don't have CR-LFs.)
  • change hw.sdCard=no to hw.sdCard=yes

this should work for everyone in new builds

Jerry101
  • 12,157
  • 5
  • 44
  • 63
afra mehrparvar
  • 259
  • 2
  • 5
  • 2
    Thanks for the link, this helped me out. The recommended solution now is to find your AVD config.ini and change hw.sdCard=no to hw.sdCard=yes. This worked for me. – Tim Malseed Nov 03 '14 at 22:37
  • yes that's new solution . u welcome :) really happy it helped u . yeah this is vry good solution . because no way one can put even with all this linux codes as long as this issue persist :) – afra mehrparvar Nov 04 '14 at 14:42
  • Amazing how much time I just lost because of this... Thanks a lot! – rectummelancolique Nov 10 '14 at 00:33
7

I think the problem here is that you forgot to set SD card size

Follow these steps to make it work:

  1. step1: close running emulator
  2. step2: open Android Virtual Device Manager(eclipse menu bar)
  3. step3: choose your emulator -> Edit -> then set SD card size

This works well in my emulator!

tipycalFlow
  • 7,594
  • 4
  • 34
  • 45
tan
  • 71
  • 1
  • 1
7

Maybe it sounds stupid but it worked for me when I had the same problem: delete the created avd and create one again through AVD Manager with a sd card of, for example, 512MB.

Check that both have the correct permissions and if not, try to change them with chmod.

And if everything still fails, repeat the process but creating both avd and sd card manually via terminal:

android create avd -n my_avd -t 7
mksdcard -l e 512M mysdcard.img
emulator -avd my_avd -sdcard mysdcard.img

Hope that helps!

Edu Zamora
  • 1,492
  • 1
  • 19
  • 30
4

I tried @user2002993 great help but it one place it need to be a little edit so I edited and here what worked for me on Android Studio, emulator android 5.

Go to your adb folder right click on blank area and select "open command window here" or if you installed adb by adb-installer open cmd and type these commands:

adb devices

It should show your emulator number and detail. Then followed command here:

adb shell

Now it should show you prompt #

su

mount -o rw,remount rootfs

chmod 777 /mnt/sdcard

exit

exit

Yeah double exit needed, now your prompt of adb shell is gone. Put a file in to your adb folder and give this command and see if it got fixed.

adb push "your file name like : 1.jpg" /sdcard/

or

adb push "your file name like : 1.jpg" /storage/sdcard/

Now in cmd it shoudl show you transfer time instead of creepy read-only thing

Levi Arista
  • 295
  • 1
  • 3
  • 13
afra mehrparvar
  • 259
  • 2
  • 5
  • and as i see unfortunately .. android studio version 8.10 and above that change a little bit studio structure give this error ...i tested with studio 8.09 and there was no such an read-only error google should fix this – afra mehrparvar Oct 30 '14 at 11:12
4

Make sure that you had given a value which is greater than zero for SD Card size in the Create AVD Window for that particular emulator.

Dipin
  • 1,085
  • 6
  • 19
3

mount -o remount, rw /sdcard

this is the correct way to remount your sdcard using your emulator.

teddy
  • 31
  • 1
2

I increased the virtual memory of sdcard up to 512 MB for the emulator and that was enough

1

I guess, you didn't insert memory size at the time of creating avd. you can do that by editing the avd. screenshot

Suresh Sharma
  • 1,826
  • 22
  • 41
0

Windows uses backward slashes, linux uses forward slashes.

nomapp
  • 1
  • 2
0

sometimes this can cause of a very simple reason, go to your list in eclipse and check whether you have set SDCard size

0

I had this problem on Android L developer preview, and, at least for this version, I solved it by creating an sdcard with a size that had square 2 size (e.g 128M, 256M etc)

Eli
  • 707
  • 8
  • 16
0

In adb version 1.0.32 and Eclipse Luna (v 4.4.1).

I found a directory in the avd /mnt/media_rw/sdcard that you can write to using the adb command. adb push {source} /mnt/media_rw/sdcard

There appears to be rw access to this directory.

Hope this helps :-)

gregrobinz
  • 23
  • 5
0

Alternate way: Dismount the drive (from settings/storage) and re-mount the sdcard also fixes the problem. (verify by moving a file from internal storage to sdcard) In any case, this simple method saved my butt this time :)

0
  1. Give any size to Sdcard in Emulator
  2. unchecked the read only option from c:\user...android\avd -> properties
  3. push a file through file explorer
  4. restart the Emulator

It will definitely works

0

With me in the end helped In the emulator to run applications manager and setting permissions for storage.

momik bęc
  • 17
  • 3
0

Try this in a Terminal Emulator as root:

restorecon -v -R /data/media
intrepidis
  • 2,870
  • 1
  • 34
  • 36
0

In Latest AVD just remove the sd card, it will work as charm. I also faced the same when it has studio managed sd card=512mb, When i selected continue with NO SD Card then its working fine. I am attaching the config.ini file of emulator

AvdId=Pixel_6_Pro_API_28
PlayStore.enabled=false
abi.type=x86
avd.ini.displayname=Pixel 6 Pro API 28
avd.ini.encoding=UTF-8
disk.dataPartition.size=4G
fastboot.chosenSnapshotFile=
fastboot.forceChosenSnapshotBoot=no
fastboot.forceColdBoot=no
fastboot.forceFastBoot=yes
hw.accelerometer=yes
hw.arc=false
hw.audioInput=yes
hw.battery=yes
hw.camera.back=virtualscene
hw.camera.front=emulated
hw.cpu.arch=x86
hw.cpu.ncore=4
hw.dPad=no
hw.device.hash2=MD5:a8abfd3536f3d35e4ba2041a7b99f40e
hw.device.manufacturer=Google
hw.device.name=pixel_6_pro
hw.gps=yes
hw.gpu.enabled=yes
hw.gpu.mode=auto
hw.initialOrientation=Portrait
hw.keyboard=yes
hw.lcd.density=560
hw.lcd.height=3120
hw.lcd.width=1440
hw.mainKeys=no
hw.ramSize=1536
hw.sdCard=no
hw.sensors.orientation=yes
hw.sensors.proximity=yes
hw.trackBall=no
image.sysdir.1=system-images\android-28\google_apis\x86\
runtime.network.latency=none
runtime.network.speed=full
sdcard.size=512 MB
showDeviceFrame=yes
skin.dynamic=yes
skin.name=pixel_6_pro
skin.path=C:\Users\User\AppData\Local\Android\Sdk\skins\pixel_6_pro
tag.display=Google APIs
tag.id=google_apis
vm.heapSize=384
Durgesh Kumar
  • 935
  • 10
  • 17
-1

make sure that you have the correct permissions.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
esse
  • 5,429
  • 3
  • 19
  • 20