23

I attempted to create an AVD for Jellybean (API 17) in Kubuntu 17.04 using the following procedure:

  1. Launch the AVD Manager from Android Studio

  2. Click the "Create Virtual Device" button:

    enter image description here

  3. Select the Nexus 4 hardware profile:

    enter image description here

  4. Click "Next"

  5. Click the "x86 Images" tab and select "Jelly Bean / 17 / x86 / Android 4.2 (with Google APIs)" image:

    enter image description here

  6. Click "Next"

  7. Leave the settings at their defaults:

    enter image description here

  8. Click "Finish"

Now, due to an unfortunate issue with Ubuntu 17.04 (and its derivatives), it is not possible to launch the emulator directly by clicking the play button next to its entry. (Clicking it does nothing.) Instead, I must launch the emulator from the terminal with:

$ cd ~/Android/Sdk/tools
$ LD_PRELOAD='/usr/$LIB/libstdc++.so.6' ./emulator -avd Nexus_4_API_17

The emulator starts and the home screen appears:

enter image description here

However, interacting with it immediately reveals that there is a problem. The camera displays an error:

enter image description here

Clicking on "Storage" in the Settings app causes the Settings app to crash.

What did I do wrong and how can I fix this?


Edit: I clicked "Show Advanced Settings" and confirmed that an SD card was indeed to be created:

enter image description here

I also confirmed that the file ~/.android/avd/Nexus_4_API_17.avd/sdcard.img.qcow2 exists.


Edit: I followed the same procedure to create a Kit Kat AVD (using the Nexus 5 hardware profile) and the issue is not present there. The SD card works as expected.


Edit: I tried using mksdcard to manually create an SD card image:

mksdcard -l TEST 100M sdcard.img

...and then passing it directly to the emulator:

emulator -sdcard sdcard.img -avd [...]

...but this made no difference.

However, I discovered something interesting after opening a root terminal on the device (using adb shell) and running the mount and df commands:

# mount
rootfs / rootfs ro,relatime 0 0
tmpfs /dev tmpfs rw,nosuid,relatime,mode=755 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
tmpfs /mnt/secure tmpfs rw,relatime,mode=700 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
/dev/block/vda /system ext4 ro,relatime,data=ordered 0 0
/dev/block/vdb /cache ext4 rw,nosuid,nodev,noatime,errors=panic,data=ordered 0 0
/dev/block/vdc /data ext4 rw,nosuid,nodev,noatime,errors=panic,data=ordered 0 0

# df
Filesystem             Size   Used   Free   Blksize
/dev                   757M    68K   757M   4096
/mnt/secure            757M     0K   757M   4096
/mnt/asec              757M     0K   757M   4096
/mnt/obb               757M     0K   757M   4096
/system                532M   349M   183M   4096
/cache                  60M    40K    60M   4096
/data                    1G    75M     1G   4096

It appears as if the SD card isn't being mounted, since /dev/block/vdd is missing in the output above and none of the partitions have a capacity of 100M.

Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
  • Hey! what is the results in External file? Sill not working? – Kaushal28 May 11 '17 at 19:40
  • @Kaushal28 Sorry, I was just eating lunch. I tried specifying the path to the `.qcow2` image for External File but it made no difference. – Nathan Osman May 11 '17 at 19:48
  • Have you tried to re-create the sdcard image file manually? https://developer.android.com/studio/command-line/mksdcard.html You can also try to start emulator via command line with `-sdcard` param. – Matteo Gaggiano Oct 25 '17 at 07:38
  • @MatteoGaggiano I gave that a shot but it still isn't working. Please see my update. – Nathan Osman Oct 25 '17 at 07:54
  • @NathanOsman from android doc `If the file isn't found, the emulator still launches, but without an SD card; the command returns a No SD Card Image warning.`. Is the warning show up? – Matteo Gaggiano Oct 25 '17 at 16:16
  • @NathanOsman another question, can you try to list all devices with `lsblk -o KNAME,TYPE,SIZE,MODEL`. What you get with `mount` and `df` doesn't include the not-mounted devices – Matteo Gaggiano Oct 25 '17 at 17:08
  • @MatteoGaggiano The `lsblk` command doesn't seem to be available :( – Nathan Osman Oct 25 '17 at 17:11
  • @NathanOsman I've downloaded and initialized a new device (Nexus 5) with JellyBean 17 Google API version without changing nothing. Same error, on Windows 10. So, the problem might be the old os with new emulated device? As a side note, when I'm trying to access to storage tab from Settings it crash. It is described here https://stackoverflow.com/questions/16854439/storage-application-stock-app-crashing-in-android-emulator – Matteo Gaggiano Oct 25 '17 at 19:50

5 Answers5

5

After some research I'm ended up to an answer: JellyBean is too old to be used on recent emulator.

If you want to continue to use this system and wanto to use also the sd card, this can be a nice workaound for you.

Launch manually the emulator as:

cd ~/Android/Sdk/emulator
LD_PRELOAD='/usr/$LIB/libstdc++.so.6' ./emulator @Nexus_4_API_17 -verbose -engine classic

Note the -engine classic that will load the old/classic qemu with kernel kerne-qemu instead of new qemu2 with kernel kernel-ranchu (available options are: auto, classic, qemu2)

Matteo Gaggiano
  • 1,254
  • 15
  • 28
1

try using Genymotion. it much faster. Genymotion operation relies on the use of Oracle VM VirtualBox in the background. This enables virtualizing Android operating systems. If you do not already have Oracle VM VirtualBox installed, you will be asked to do so prior to installing Genymotion.

Etornam
  • 413
  • 1
  • 3
  • 10
0

When you create an AVD it's possible to say whether to emulate SDCard or not (and of what size). Looks like you simply did not specify the SDCard presence. Edit your AVD settings and make sure you have explicitly requested for SDCard support. I think this options in Advanced settings in your step 7.

Kaushal28
  • 5,377
  • 5
  • 41
  • 72
0

For settings issue

Edit the hardware profile and change the dimensions to 4.2 inches(Not sure Why? But i think upto 17 max resolution available was 4.2 inches).

Reboot the device

Your settings will start working.

For camera

The issue is the file system which is in read only mode. You need to change the file system. Check this link.

After changing the file system push few images and restart.

Another issue i found that there is no DCIM folder present. Try creating the /mnt/sdcard/DCIM and add few images too.

Reboot again. Everything will start working.

Talha Q
  • 4,350
  • 4
  • 28
  • 40
  • I adjusted the hardware profile to 4.2" but that didn't make a difference, even after rebooting the virtual device. I also tried remounting `/` and `/system` as `rw` but that didn't make a difference. – Nathan Osman Oct 25 '17 at 05:46
0

You can use genymotion: https://www.genymotion.com/

Genymotion is an emulator using x86 architecture virtualization, making it much more efficient!

Taking advantage of OpenGL hardware acceleration, it allows you to test your applications with amazing 3D performance

http://hackpundit.com/android-emulator-genymotion-installation/

Misagh
  • 3,403
  • 1
  • 20
  • 17