Monthly Archives: January 2014

Developing first Android app on Windows 8 : Step 0 – Intro

Wanted to try setting up a development environment on my Windows 8 desktop, where I could create a basic Android app, compile it and run it on my Nexus 7 tablet.

Step 1 – Installing Android Developer Tools
Covers the setting up of the development environment, an Ubuntu Linux virtual machine running within VMware Player.  Plus the downloading of Android Development Tools.

Step 2 – Enable developer mode on physical Android device
Enabling developer mode on Nexus 7 running Android 4.4.2 so that the newly compiled app can be transferred to it and be run there.

Step 3 – Hello World
Using the eclipse tool to create an “empty” Android app which merely outputs “Hello World!”.  Copy it to the Nexus 7 via USB and run it there.

Step 4 – Command line (later!)
Repeat step 3 without using the eclipse tool.  Just use command line.

Developing first Android app on Windows 8 : Step 3 – Hello World

Follows on from Developing first Android app on Windows 8 : Step 1 – Installing Android Developer Tools

Within eclipse, click File->New->Android Application Project.
30newproj
At “Creates a new Android Application”, give the application, project and package a name.31create
At “Configure Project”, take the defaults.
32create
At “Configure Launcher Icon”, take the defaults
33create
At “Create Activity” take the defaults.
34create
At “Blank Activity” take the defaults and press Finish.
35create
Eclipse now displays the project and code generated.
36create

Make the Android device available to this VM via removable devices.
80connect

This generates a few lines in syslog.

steve@ubuntu:~/adt-bundle-linux-x86_64-20131030/eclipse$ grep usb /var/log/syslog|tail -6
Jan 13 14:03:05 ubuntu kernel: [ 7039.022771] usb 1-1: new high-speed USB device number 5 using ehci-pci
Jan 13 14:03:05 ubuntu kernel: [ 7039.241720] usb 1-1: New USB device found, idVendor=18d1, idProduct=4e42
Jan 13 14:03:05 ubuntu kernel: [ 7039.241724] usb 1-1: New USB device strings: Mfr=2, Product=3, SerialNumber=4
Jan 13 14:03:05 ubuntu kernel: [ 7039.241746] usb 1-1: Product: Nexus 7
Jan 13 14:03:05 ubuntu kernel: [ 7039.241749] usb 1-1: Manufacturer: asus
Jan 13 14:03:05 ubuntu kernel: [ 7039.241750] usb 1-1: SerialNumber: 015d4a5ed73c1a0b
steve@ubuntu:~/adt-bundle-linux-x86_64-20131030/eclipse$ date
Mon Jan 13 14:04:39 PST 2014
steve@ubuntu:~/adt-bundle-linux-x86_64-20131030/eclipse$

And a new entry visible via lsusb.

steve@ubuntu:~/adt-bundle-linux-x86_64-20131030/eclipse$ lsusb
Bus 001 Device 005: ID 18d1:4e42 Google Inc. Nexus 7 (debug)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 004: ID 0e0f:0008 VMware, Inc. 
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
steve@ubuntu:~/adt-bundle-linux-x86_64-20131030/eclipse$

Compile+run the newly generated code from within eclipse.
90run
91run
92run

The Android device should now be running your app.
Screenshot_2014-01-13-20-04-47

Developing first Android app on Windows 8 : Step 2 – Enable developer mode on physical Android device

Previous step : Developing first Android app on Windows 8 : Step 1 – Installing Android Developer Tools

Enable developer mode on the phone/tablet so we can send our example app to the device.
Go to the “Settings” app and select “About tablet”.

50about
Press the “Build Number” line repeatedly.
60steps4
61steps1
62nowdev
You are now a developer.
A new “Developer options” now appears on the “Settings” window.
63devopt
The Developer options screen gives these various options.
64devoptEnable USB debugging, so that apps can be sent over USB.
64devopt
65usbdebug

Next step : Developing first Android app on Windows 8 : Step 3 – Hello World

Developing first Android app on Windows 8 : Step 1 – Installing Android Developer Tools

Notes on developing first android app on a desktop PC running Windows 8.  Using a Linux VM on there rather than native Windows.

Get free Ubuntu Linux distribution .iso file from (at the time of writing it is v13.10, 883MB) http://www.ubuntu.com/download/desktop/questions?distro=desktop&bits=64&release=latest

Get free VMware Player for Windows (at the time of writing it is v6.0.1 build 1379776, 93MB) https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0

Install VMware Player.
01vmware-player-install
02vmware-player-install
03vmware-player-install

Run VMware Player, create a new Ubuntu VM, pointing it at the .iso downloaded earlier.  Take all the default options.
04create-vm
05create-vm

06create-vm

07create-vm

08create-vm

09create-vm

10create-vm

Launch the Ubuntu VM, which then starts the installation of Ubuntu itself.

Once installed, logon and run command startx.

Get a terminal by pressing Control + Alt + t.

steve@ubuntu:~$ cat /etc/lsb-release
 DISTRIB_ID=Ubuntu
 DISTRIB_RELEASE=13.10
 DISTRIB_CODENAME=saucy
 DISTRIB_DESCRIPTION="Ubuntu 13.10"
 steve@ubuntu:~$ uname -a
 Linux ubuntu 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
 steve@ubuntu:~$

Update package info.

steve@ubuntu:~$ sudo apt-get update

Download the Android ADT (Eclipse IDE and Android SDK tools).  Download from site http://developer.android.com/sdk/index.html

steve@ubuntu:~$ wget http://dl.google.com/android/adt/adt-bundle-linux-x86_64-20131030.zip
 --2014-01-12 12:30:39-- http://dl.google.com/android/adt/adt-bundle-linux-x86_64-20131030.zip
 Resolving dl.google.com (dl.google.com)... 173.194.34.97, 173.194.34.104, 173.194.34.98, ...
 Connecting to dl.google.com (dl.google.com)|173.194.34.97|:80... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 497171697 (474M) [application/zip]
 Saving to: ‘adt-bundle-linux-x86_64-20131030.zip’
[========================================================================] 497,171,697 12.9MB/s in 37s
2014-01-12 12:31:16 (12.9 MB/s) - ‘adt-bundle-linux-x86_64-20131030.zip’ saved [497171697/497171697]
steve@ubuntu:~$

Unzip it

steve@ubuntu:~$ unzip -q adt-bundle-linux-x86_64-20131030.zip
steve@ubuntu:~$

If we run eclipse now, we’ll get this error, due to 32-bit libraries not being there.
23eclipsefail

So install the libraries manually, to avoid the error altogether:

steve@ubuntu:~$ sudo apt-get install libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 libglu1-mesa:i386
 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 [snip]
 Setting up libpangox-1.0-0:i386 (0.0.2-4) ...
 Setting up libtxc-dxtn-s2tc0:i386 (0~git20121227-1) ...
 update-alternatives: using /usr/lib/i386-linux-gnu/libtxc_dxtn_s2tc.so.0 to provide /usr/lib/i386-linux-gnu/libtxc_dxtn.so (libtxc-dxtn-i386-linux-gnu) in auto mode
 Processing triggers for libc-bin ...
 steve@ubuntu:~$

Launch eclipse

steve@ubuntu:~$ cd adt-bundle-linux-x86_64-20131030/eclipse
steve@ubuntu:~/adt-bundle-linux-x86_64-20131030/eclipse$ ./eclipse

22eclipse
24eclipsok

Next step : Developing first Android app on Windows 8 : Step 2 – Enable developer mode on physical Android device