Ubuntu-错误: 创建 SD 卡失败

我看到很多关于写 SD 卡的帖子,但我相信我的问题是不同的。在制作 AVD 的过程中,我无法创建 SD 卡。

我最初尝试使用 Android SDK 和 AVD Manager 来做这件事,选择
Name : my _ avd 名称 : my _ avd
目标 : Android 2.2-API 级别8
SD 卡 : 大小: 1024MiB
Skin : 内置: 默认(HVGA)
硬件 : 属性: 抽象 LCD 密度,值: 160

这会弹出一个窗口,其中显示如下信息:
“创建 AVD‘ my _ AVD’的结果:
错误: 创建 SD 卡失败。”

我试图从命令行重复这个过程,却收到了类似的错误:

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.

尝试遵循使用 mksdcard 的说明同样是徒劳的; 我认为我基本上缺乏 Linux 体验可能会给我带来问题。当我尝试使用 mksdcard 时,它只报告找不到文件或目录。Mksdcard 工具是否可以在 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

我已经将 android 工具目录添加到 PATH 变量中,但是我感觉明显还缺少其他东西。也许是某种进入权?

尝试用 sudo 运行 android 命令似乎也没有帮助:

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.

我甚至尝试安装 Eclipse 和 ADT 插件,并从那里运行管理器,但没有用。如有任何建议,我将不胜感激。高级警告,我是一个 Linux 新手,所以即使它看起来是一个显而易见的事情来检查,我仍然可能错过它。

63256 次浏览

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.

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

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

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.

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

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

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

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

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

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++

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.

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.

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.

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
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++/**

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

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 *

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:

enter image description here

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/

enter image description here

After installing Microsoft Visual C++, my problem was fixed. I was able to create AVD successfully.