Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Setting Up Android on an Intel NUC

Today I managed to get Android running on an Intel NUC computer. This sounds easier than it was as there were multiple issues that had to be overcome.

Steps

Download Android-x86 ISO

I downloaded Android-x86 from here, and made sure to get the x86_64 ISO file version to have 64 bit support. This will install Android 7.1.1 at the time of writing this article. At one point I tried Phoenix OS, which was just terrible.

Create USB Stick Installer

At first, I used unetbootin to set up a USB stick installer. It's pretty straightforward and will work.

I also later used a special device that emulated a CD drive which also worked, but I had to enable booting from "optical drive" for this to work.

I would recommend using a decent stick, such as a Sandisk ultra as this will save a lot of time. Initially I used a Kingston DataTraveler G4 which took an age compared to just a few minutes on the Sandisk.

Installing - Black Screen of Death Fix

  1. Boot up the NUC with the USB stick plugged in.
  2. Ensure booting from the USB stick is enabled in the BIOS.
  3. When booting from the USB stick the GRUB menu will default to running in "live mode", which runs okay, but when I wanted to install to the local hard disk, it would always give me a black screen.
    • The solution to this was to disable UEFI boot options in the BIOS, so we would always boot from legacy.

Don't Use Auto/Fast Install - Allows Us To Edit Config Files Later

We need to install by using the normal, manual installation method from the GRUB menu, rather than using the automatic/fast installation method.

At some point during this installation method, it will ask us if we wish to install /system as a read/write partition. It is cricitical that we do this so that we can edit some of the configuration files later.

No Touchscreen Fix

At one point, I thought that the touchscreen wouldn't work. Luckily, solving this is as easy as turning off the computer, unplugging the mouse and keyboard, and booting back up.

Screen Rotation Fix

There is no gyroscope in the NUC, so it will default to the default screen orientation. Unfortunately, we are setting up a portrait unit so everything was 90 degrees off. Using the built-in rotation settings didn't work. Neither did installing and using any of the rotation apps from the play store. We also hunted through the monitor settings to see if we could change it through that, but alas no.

We found a solution was to install the termux app, and use it to run the following commands (you could use the built-in emulator, but we need termux for a specific reason later):

su
setprop config.override_forced_orient true
stop;start

When combined with this screen rotation app, it worked for the next reboot, but we lost internet access for some reason.

Making Rotation Permanent

Make sure the screen rotation app is set to boot up on start, and set it to have a rotated image.

Open up the termux app, and install vim:

pkg install vim

Then make two copies of the /etc/init.sh configuration file, one should act as a backup and I labelled it as /etc/init.sh.bak. Use this if stuff goes horribly wrong.

Edit the other copy of the file and find the line that sets has_sensors to false. It should be at the end of a switch statement. Change it to true.

Overwrite the /etc/init.sh file with this modified version, and set its permissions with the following command as the su user (by having run the su command earlier):

chmod 744 /etc/init.sh

This makes the file only editable by root, but all other users have the read permission.

Reboot

Now reboot and you have a fully working system with the screen rotated how you want. The screen rotation app can be used to set the orientation you like.

References

Last updated: 9th June 2019
First published: 6th June 2019