Install Android Studio on Ubuntu

Ubuntu

Android Studio is a great development environment and is available on Ubuntu. I’m using Ubuntu Mate 16.10 “Yakkety Yak”.
 
First install a Java Development Kit (JDK). OpenJDK is pre-installed or you can use Oracle Java 8 (there is a great guide here). I don’t wish to argue over your choice – I need to use the latter (my tutor does). Download Android Studio here. – I extracted it to /opt; ran the installer; and used my home folder for the SDK. If you are using 64 bit, you need the 32 bit GNU standard C++ library:
sudo apt install lib32stdc++6

For Arch you need to enable “multilib” repository:

<code><span class="pln">sudo pacman </span><span class="pun">-</span><span class="typ">Syu</span> <span class="pun">&amp;&amp;</span><span class="pln"> sudo pacman </span><span class="pun">-</span><span class="pln">S multilib</span><span class="pun">/</span><span class="pln">lib32</span><span class="pun">-</span><span class="pln">libstdc</span><span class="pun">++</span><span class="lit">5</span><span class="pln"> multilib</span><span class="pun">/</span><span class="pln">lib32</span><span class="pun">-</span><span class="pln">zlib</span></code>

Virtualisation support is interesting. I read two tutorial and Google’s guide. The former makes reference to command line options not in version 2.2.2. These posts suggest this is a bug, but it may now be default behaviour. First enable that virtualisation in BIOS (check if enabled using “kvm-ok”).

sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
sudo adduser dougie kvm
sudo adduser dougie libvirtd

This results in an error.
screenshot-at-2016-11-25-21-16-19

Using the system version of libstdc++.so.6 works. Add the following to /etc/environment:

ANDROID_EMULATOR_USE_SYSTEM_LIBS=1

It seems snappy but with no feedback I’m unsure if accelerated.

So I now have a development environment set up for my project. The next hurdle is to choose a title. So far it is a: development project; distributed application; and uses Android.

TM470

After a false start when The Open University opened the TM470 module site, we got back on track on Wednesday. Although the module doesn’t start until February, I need to decide a project to assign a tutor.
 
I read the study guide and project choice pages. Self development is key, by being a reflective practitioner.
 
My project can be research, development or evaluation. It should develop knowledge acquired at level three, where I took:
  • Developing Concurrent Distributed Systems (M362),
  • IT Systems Planning for Success (TM353) and
  • Software Engineering (TM354).
I also want to use:
  • Algorithms Data Structures and Computability (M269) as I enjoyed the subject and
  • Web Technologies (TT284) as I enjoyed mobile application development and gained a distinction.
Developing a mobile application with a software engineering approach makes sense. There are techniques and approaches from TM353 that help. For TT284 I used MIT’s AppInventor but would like to use Google’s Android Studio. I worked through the tutorials and it offers a comprehensive suite of tools and runs on Ubuntu.
 
The trick is to be find an achievable solution to a defined problem. I have ideas but have lots of research ahead of me. I am writing down ideas in a notebook as I get them and aim to decide in the next few weeks.
 
Throughout I am going to blog, more for myself than anything else. I’ve noticed students reaching out for support on Twitter. While being careful about plagiarism, thought’s trigger conversations we wouldn’t otherwise have.

Install Android 5.0 (Lollipop) on Nexus 7

Update: Lollipop is now available OTA on Nexus 7!

Why? Why not? This will remove any custom boot loader and wipe the tablet. I did this from Windows 7 – in Linux its pretty much the same but doesn’t require the Google USB driver and you can obviously extract the image using tar from the command line.

Download the Android SDK, run the Android SDK Manager and install Google USB Driver (from Extras) and Android SDK Platform-tools (from Tools). The former are installed to AppData\Local\Android\android-sdk\extras\google\usb_driver by default. If you’re unfamiliar with USB drivers Google have a guide.Google USB Driver

Your device’s boot loader needs to be unlocked then boot in to the boot loader (hold down power and volume down button when turning on).

Download the image for your device (I have a 2012 WiFi – codename “nakasi”). Uncompress the tgz file and then the resulting tar file – 7-zip will do the trick on Windows.

Add the location of the Android SDK platform tools to your path will speed up the command line part. Open a command prompt and go to the folder you extracted the image to.

Check that the device is recognised by typing fastboot devices – if there is an output then all is well. Now run flash-all.bat – this takes a while (159.617 seconds on my Samsung RV511), when it is complete it will reboot the tablet. Rebooting took around five minutes on the first boot.

Problems updating Nexus 7 (grouper) to Android 4.4.2

Latest update failed (4.3 to 4.4.2 I think) – just a forever spinning Nexus logo. Overwrote the tablet with a stock Nexus 7 (nakasi) image and all is well, besides needing to reconfigure everything and put my files back on it (thankfully Moon Reader Pro syncs positions with Dropbox/Google Drive).

You need the Android SDK installed (remember to add it to your path) and to have rooted the device – both covered in an earlier post. On the device hold down the power, volume up and down keys until the rescue screen appears.

Connect with USB and open a command prompt/terminal then type:

adb reboot bootloader

Download a stock image from Google – the Nexus 7 (nakasi) is this one. Decompress it and go to that folder in the command prompt/terminal, run either flash-all.bat (Windows) or flash-all.sh (Linux) and follow the prompts.

Nexus 7 custom firmware

Although the Google Nexus 7 is pretty muck stock Android, I thought I’d give Cyanogenmod a try. Installing a custom firmware involves three steps – unlocking, installing a custom recovery mode, and installing the custom firmware. Oh and I’m doing this in Windows 7. There is also a very good guide on the Cyanogenmod Wiki which I followed. As I often do, this blog post is more to remind me what to do.

Setting up the tool chain

The Android Development Kit provides two useful tools – Android Debug Bridge (adb) lets you communicate with a connected Android device; and Fastboot which when in a boot loader allows flashing, erasing and rebooting. Once downloaded, unzip it to your folder of choice and add the sdk/platform-tools folder to your path (in Windows 7 you can do this by going to the folder in question, copying the address line and then right clicking My Computer→Properties→Advanced System Settings→Environment Variables, select Path and Edit then add the line with a leading semi-colon). The ADK requires the Google USB Driver and that you enable USB debugging (Settings→About and tapping “Build number” until Developer mode is enabled, then you can select USB debugging from Settings→Developer Options).

Unlocking the device

Connect the Nexus 7 via USB and open a command prompt in Administrator mode. Type:

adb reboot bootloader
fastboot oem unlock

The Nexus 7 will display a disclaimer – use the volume buttons to scroll through options and the power button to accept. Reboot the Nexus 7.

Custom recovery console

Turning the Nexus 7 on by holding down the volume up, volume down and power buttons. The stock recovery partition lets you do a factory reset but not much else so I replaced it with ClockworkMod which will install custom firmware and allow you to make backups.

First download the image, the Nexus 7 is available here. From the terminal:

adb reboot bootloader
fastboot devices

If there is no device listed, then you should check that the USB drivers are installed correctly. Ensure you’re in the correct folder and flash the Nexus 7:

fastboot flash recovery RECOVERY_FILE_NAME.img

Finally reboot into the new recovery image:

fastboot boot RECOVERY_FILE_NAME.img

Installing Cyanogenmod

Download Cyanogenmod – I choose the nightly build. You can also download Google apps here. ClockworkMod can install from SD card, which the Nexus 7 doesn’t have – but there is a folder called /sdcard/. From the terminal, use ADB to push the two files (obviously use the filenames you downloaded):

adb push cm-10.1-20130706-NIGHTLY-grouper.zip /sdcard/
adb push gapps-jb-20130706 /sdcard/

Now using the volume and power buttons to navigate the ClockworkMod menus:

  1. Back up the Nexus 7 (backup and restore→backup)
  2. Wipe data/factory reset
  3. Install the two zip files (install zip from sdcard→choose zip from sdcard)
  4. Reboot (reboot system now)

You should now have Cyanogenmod installed.

Nexus 7 screen not coming on

My Google Nexus 7 had a weird fault earlier, its screen wouldn’t come on – just what you need before a nine hour flight. I tried a reset – it appeared to be caught in a loop with some static displayed on screen. I thought I might remove the back cover, disconnect the battery and take it from there.

Glad I did – the battery connector wasn’t engaged properly. A piece of insulating material had got in the way, preventing the connector locking in place. It must have worked loose.

Since then I’ve seen a few threads on Reddit with people mentioning that disconnecting and reconnecting the battery had fixed the same issue. I wonder if this is something more common than I thought?