[android-emulator] Android Emulator sdcard push error: Read-only file system

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?

This question is related to android-emulator

The answer is


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


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.


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)


Try this in a Terminal Emulator as root:

restorecon -v -R /data/media

  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


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 :)


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 :)


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


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!


make sure that you have the correct permissions.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

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


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


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


mount -o remount, rw /sdcard

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


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


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 :-)


Windows uses backward slashes, linux uses forward slashes.


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.


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!


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