Ubuntu - Error: Failed to create the SD card
AndroidLinuxUbuntuAndroid Problem Overview
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:
alex@alex-desktop:~$ 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?
alex@alex-desktop:~$ mksdcard 1024M ./sdcard.iso
bash: /home/alex/android-sdk-linux_x86/tools/mksdcard: No such file or directory
alex@alex-desktop:~$ 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:
alex@alex-desktop:~/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.
Android Solutions
Solution 1 - Android
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.
Solution 2 - Android
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
Solution 3 - Android
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
Solution 4 - Android
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++
Solution 5 - Android
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).
Solution 6 - Android
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
Solution 7 - Android
alex@alex-desktop:~$ mksdcard 1024M ./sdcard.iso
bash: /home/alex/android-sdk-linux_x86/tools/mksdcard: No such file or directory
alex@alex-desktop:~$ 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 :)
Solution 8 - Android
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.
Solution 9 - Android
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++/**
Solution 10 - Android
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
Solution 11 - Android
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.
Solution 12 - Android
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:
Solution 13 - Android
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.
Solution 14 - Android
MyOS is Oracle Unbreakable Linux 6 - to solve this issue I had to install libstdc++-4.4.6-3.el6.i686 package.
Solution 15 - Android
After a lot of installing and not getting any result I found this and it worked.
This happens because some executable files in sdk/tools
cannot be executed. Go to your Android Studio and Android SDK folders and make all directory and files executable by this command:
chmod +x -R *
Solution 16 - Android
Try moving the android sdk folder to home folder. It works.
Solution 17 - Android
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.
Solution 18 - Android
For the people who faced the same issue on windows. For me it was because mksdcard.exe tool was unable to run successfully. Some SDK tools such as mksdcard.exe require Microsoft Visual C++ runtime. So go to your System properties and check your System type:
Then based on your system type,(for me it was x64) download/update the latest Microsoft Visual C++ Redistributable for Visual Studio 2019 from the link https://visualstudio.microsoft.com/downloads/
After installing Microsoft Visual C++, my problem was fixed. I was able to create AVD successfully.