Home » Android » Ubuntu – Error: Failed to create the SD card

Ubuntu – Error: Failed to create the SD card

Posted by: admin November 30, 2017 Leave a comment

Questions:

I see a lot of posts about writing to the SD card, but I believe my problem is different. I am unable to create the SD card during the process of building an AVD.

I initially tried to use the Android SDK and AVD Manager to do this, selecting

Name: my_avd

Target: Android 2.2 – API Level 8

SD Card: Size: 1024 MiB

Skin: Built-In: Default (HVGA)

Hardware: Property: Abstracted LCD Density, Value: 160

This pops up a window with the message:

“Result of creating AVD ‘my_avd’:

Error: Failed to create the SD card.”

I tried to repeat the process from the command line, receiving a similar error:

[email protected]:~$ android create avd -n my_avd -t 1 -c 1024M
Android 2.2 is a basic Android platform.
Do you wish to create a custom hardware profile [no]no
Error: Failed to create the SD card.

Attempting to follow instructions for using mksdcard was equally unproductive; I think my basic lack of linux experience may be causing me a problem here. When I try to use mksdcard, it just reports that it cannot find the file or directory. Is the mksdcard tool available for use this way in linux?

[email protected]:~$ mksdcard 1024M ./sdcard.iso
bash: /home/alex/android-sdk-linux_x86/tools/mksdcard: No such file or directory
[email protected]:~$ sudo android create avd -n my_avd -t 1 -c 1024M

I’ve added the android tools directory to my PATH variable, but I feel like there is obviously something else I’m missing. Perhaps some kind of access rights?

Attempting to run the android command with sudo did not seem to help either:

[email protected]:~/android-sdk-linux_x86/tools$ sudo ./android create avd -n my_avd -t 1 -c 1024M
Android 2.2 is a basic Android platform.
Do you wish to create a custom hardware profile [no]no
Error: Failed to create the SD card.

I even tried installing Eclipse and the ADT plugin and running the manager from there to no avail. Any tips would be most appreciated. Advanced warning that I am somewhat of a novice Linux user, so even if it seems like a no-brainer obvious thing to check, I could still have missed it.

Thanks!

Answers:

So I found the problem. I was using a 64-bit Linux install, which did not have the ia32-libs package installed by default. The mksdcard utility will not run without this package. After installing it, I was able to build the AVD without a problem using the AVD manager.

Questions:
Answers:

On Ubuntu 16.04 LTS x64, using Android Studio 2.1 (also tested on 2.3.3), run from a terminal:

sudo apt-get install lib32stdc++6

Questions:
Answers:

I had the same error like you and I have just solved it, so maybe it can help you (though I don’t think your error is caused by the same problem like me).

I found that all tools in ../tools don’t have the permission to excute, so I used

chmod -R 777 ../tools

from the command line and it finally works

Questions:
Answers:

As others have already written, the problem is that your Linux distro is a 64-bit one and, at present, Android Virtual Device (AVD) needs the x86 library to work correctly.

Someone has suggested to install ia32-libs. However, in Ubuntu 14.04 LTS you won’t find this library.
I solved using these alternative libs: lib32z1, lib32ncurses5, lib32bz2-1.0 and lib32stdc++.

sudo apt-get update
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++

Questions:
Answers:

I just encountered the same problem. NONE of the SDK tools will run on 64-bit Ubuntu without installing ia32-libs (EXAMPLE: sudo apt-get install ia32-libs).

Questions:
Answers:
[email protected]:~$ mksdcard 1024M ./sdcard.iso
bash: /home/alex/android-sdk-linux_x86/tools/mksdcard: No such file or directory
[email protected]:~$ sudo android create avd -n my_avd -t 1 -c 1024M

I have found this problem & i find a way
first:

cd /home/alex/android-sdk-linux_x86/tools/

then write this:

sudo chmod 755 mksdcard
mksdcard 1024M ./sdcard.iso
sudo android create avd -n my_avd -t 1 -c 1024M

it should work 🙂

Questions:
Answers:

If you are using Kali, Debian Jessie (or Ubuntu 13.10+), try

sudo apt-get install lib32stdc++6

instead of the ia32-libs mentioned above.

Questions:
Answers:
sudo apt-get install lib32stdc++6

After this you might get following errors

Cannot launch AVD in emulator.
Output:
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  49
  Current serial number in output stream:  48
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  49
  Current serial number in output stream:  48
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
emulator: WARNING: VM heap size set below hardware specified minimum of 228MB
X Error of failed request:  BadValue (integer parameter out of range for operation)
emulator: WARNING: Setting VM heap size to 384MB
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  33
  Current serial number in output stream:  34
QObject::~QObject: Timers cannot be stopped from another thread

Use these 3 commands to solve those

mv ~/Android/Sdk/tools/lib64/libstdc++/libstdc++.so.6{,.bak}
mv ~/Android/Sdk/tools/lib64/libstdc++/libstdc++.so.6.0.18{,.bak}
ln -s /usr/lib/libstdc++.so  ~/Android/Sdk/tools/lib64/libstdc++/**

Questions:
Answers:

Also had this problem and after installing the i386 package I was able to create a SD-card for my Android emulator
I had to do two steps

sudo apt-get update
sudo apt-get install ia32-libs

After this was finished, I was able to create an emulator with a SD-card attached

Questions:
Answers:

In elementary OS and ubuntu, the solutions was to install the following packages

sudo apt-get install lib32ncurses5 lib32z1
sudo apt-get install libgcc1:i386

Questions:
Answers:

I had a different problem: platform-tools was in my path but tools was not. So, everything worked except that the SDCard image was not created. There was no notice of this when I created the avd in eclipse and the virtual device was created with a really small sd card causing it to constantly throw the media not available error on app install.

Questions:
Answers:

I am running Fedora 64 and had the same problem. The information on this page helped me.

http://iexcel.wordpress.com/2010/01/25/ia32-libs-for-android-sdk-on-fedora-12-x86_64/

Questions:
Answers:

On debian testing, when i tried to run ./tools/mksdcards, i received the error:

error while loading shared libraries: libstdc++.so.6: 
cannot open shared object file: No such file or directory

Installing lib32stdc++6 resolves the problem, and was possible to create the avd.

Questions:
Answers:

I had a different problem using 32bit Ubuntu. When i tried to run mksdcard by hand, I was getting a file not found error.

The problem was open-jre/jdk. I installed oracle java and the problem was fixed. Unfortunately you can no longer install oracle java through apt/synaptic and have to jump through some extra hoops:

https://github.com/flexiondotorg/oab-java6

Questions:
Answers:

MyOS is Oracle Unbreakable Linux 6 – to solve this issue I had to install libstdc++-4.4.6-3.el6.i686 package.

Questions:
Answers:

Try moving the android sdk folder to home folder. It works.

Questions:
Answers:

I had the same problem. After troubleshooting, I came to know that, it was because of my Windows is 32bit and my mksdcard is compatible with 64 bit only. Then I just copied a mksdcard of 32 bit to tools folder, and deleted the older one. It solved my problem.