Wednesday, October 4, 2017

How To Use Android Studio To Develop Android Software For Beginners - Part 1

This is a continuation of my previous articles on installing Oracle Java and Android Studio on a PC. In my previous article here, I mentioned in STEP 2, that the Google written article 'Build your first app' (as part of the training for new users of Android Studio) was available on-line here.

This article was written to help anyone who is attempting to follow the instructions found at that URL - especially for those trying to locate the icons to press during the process. This article is also designed to be architecture friendly as possible. This means that you can run it on almost every OS, be it a MacIntosh, Windows, and almost all flavors of Linux.

First make sure that you have installed Oracle's Java JDK and Google's Android Studio on the PC that will be used. Then click here, read the introduction and then click the 'Get started' link and follow the instructions below.
  1. Read 'Create an Android Project' section first, then implement them. This is similar to the instructions in my article in STEP 4. Once completed, click on the 'Run your app' link.

  2. Read 'Run Your App' section first, then implement them. This is similar to the instructions in my article in STEP 6 and STEP 7, except it is in the reverse order. Once completed, click on the 'Build a Simple User Interface' link.

  3. This is where this article provides you with additional information on where the various icons are located in your Android Studio IDE. In the section titled 'Open the Layout Editor', item (2), you can either click on the items in the menu or click the Project icon, as indicated by the red arrow below.


    Item (3) mentioned the 'Design' tab and this is indicated by the red arrow as shown below.


    Item (4) mentioned the 'Show Blueprint' icon and this is indicated by the red arrow as shown below.


    Item (5) mentioned the 'Hide Constraint' icon and this is indicated by the red arrow as shown below.


    Item (6) mentioned the 'Turn On Autoconnect' icon and this is indicated by the red arrow as shown below.


    Item (7) mentioned the 'Default Margins' icon and this is indicated by the red arrow as shown below.


    Item (8) mentioned the 'Device in Editor' icon and this is indicated by the red arrow as shown below.


  4. After confirming that what you have seen in Android Studio resembles what you see in the instructions, you can proceed with the next steps. Else go back and check your work.


  5. NOTE: It does not matter if the figure shows API 26 or API 25. The instructions were written when Android Oreo 8.0 was still not available.


  6. In the section titled 'Add a text box', item (1) mentioned the 'TextView' in the 'Component Tree' which is indicated by the red arrow as shown below.


  7. In the same section, item (2) mentioned the 'Palette' window and the 'Plain Text' in the design window which is indicated by the red arrows as shown below.


  8. In the same section, item (3), item (4), and item (5) gives the instructions for creating a EditText widget on the design editor.




  9. After confirming that what you have seen in Android Studio resembles what you see in the instructions, you can proceed with the next steps. Else go back and check your work.

  10. In the section titled 'Add a button', item (1) mentioned the 'Palette' in the 'Widgets' and 'Button' which is indicated by the red arrow as shown below.



  11. Item (2) asks you to create a constraint between the button and the text box. The result is as shown in the figure below.



  12. Item (3) asks you to create a constraint between the text baselines. The Baseline Constraint icon is as shown in the figure below via the red arrow. The final result is as shown in the figure.



  13. After confirming that what you have seen in Android Studio resembles what you see in the instructions, you can proceed with the next steps. Else go back and check your work.

  14. In the section titled 'Change the UI strings', the 'Show Design' icon was mentioned. This can be found in Android Studio as indicated by the red arrow below.



  15. In the same section, item (1), it was required that you open the 'strings.xml' file. To do so, first you have to click the 'Projects' icon - the 'Projects' window will replace the 'Palette' window. Now navigate the 'app' folders (by clicking on the 'arrows' to the left of the name) to find the 'strings.xml' file. Double-click on the name of the file to open it as shown.



  16. In item (2), you are asked to open the 'Translation Editor'. This item can be found at the place indicated by the red arrow in the figure below. The window as shown below will appear.




  17. In item (3), you are asked to add a key. This 'Add Key' icon can be found at the place indicated by the red arrow in the figure below. Repeat the procedure for item (4).



  18. In the following section, item (1), says to make sure that the 'Properties' window on the RIGHT sidebar is visible. This is where the confusion lies - especially when Google uses the WRONG icon to denote the 'Properties' item. The icon as shown can only be found on the LEFT sidebar (under the '7:Structure' words) as shown by the red arrow in the figure below. Note the 'Properties' window will automatically be revealed once you select the correct item in the design pane.



  19. As indicated by the instruction (2), locate the 'hint' property and click on the 'Pick a Resource' icon as shown by the red arrow in the figure below. Then double-click on the edit_message item.




  20. As per instruction (3) delete the text property as shown by the red arrow.



  21. As per instruction (4) locate the text property as shown and click on 'Pick a Resource' icon as shown by the red arrow. Then double-click on the button_send item.




  22. In the following section titled 'Make the text box flexible', which says to click on the 'Show Blueprint' icon. The correct icon is as indicated by the red arrow in the figure below. Press it to continue.



  23. In the same section and as per instruction (1) click 'Center Horizontally' as shown by the red arrow below. After confirming that what you have seen in Android Studio resembles what you see in the instructions, you can proceed with the next steps. Else go back and check your work.




  24. As per instruction (2) set the right and left margins of the button to 16dpi as shown by the red arrows in the figures below.




  25. As per instruction (3) set the only the left margin of the text box to 16dpi as shown by the red arrow in the figure below.



  26. Still viewing the text box properties, click the width indicator as shown by the red arrow in the figure below. Keep clicking until you see the 'Match Constraints' words, as in figure 33 below.




  27. After confirming that what you have seen in Android Studio resembles what you see in the instructions and the figure below (as indicated by callout 1), you can proceed with the next steps. Else go back and check your work.



  28. After confirming that what you have seen in Android Studio resembles what you see in the instructions as shown in the figure below, you can proceed with the next steps. Else go back and check your work.



  29. If it seems your layout did not turn out as expected, check your XML code with the one given in the instruction - they should be similar. If your attributes appear in a different order, that's okay.

  30. In the following section titled 'Start Another Activity', item (1), add the sendMessage() method stub to the MainActivity.java file as shown. You will see an error because Android Studio cannot resolve the View class used as the method argument. Click to place your cursor on the View declaration, and then perform an Alt + Enter (or Option + Enter on Mac) keypress. Then, select Import class from the menu.



  31. In the activity_main.xml file, click on the button and locate the onClick property. Then select sendMessage [MainActivity] from the drop-down list as indicated by the red arrow in the figure below.


  32. In the following section titled 'Build an Intent', add the EXTRA_MESSAGE constant and the sendMessage() code as shown below. Android Studio will again encounter Cannot resolve symbol errors, so place the cursor on the errors, and press Alt + Enter (or Option + Return on Mac) to resolve the errors (except for DisplayMessageActivity which will be resolved soon).


  33. In the following section titled 'Create the second activity', items (1) and (2), create an empty activity (see below) and enter 'DisplayMessageActivity' for Activity Name and click finish as shown below.



  34. In the following section titled 'Add a text view', items (1), select the activity_display_message.xml file as shown below.


  35. In the same section, items (2), click Turn On Autoconnect in the toolbar as shown below.


  36. Create a TextView from the palette, and place it on the layout. Then create one more constraint from the top of the text view to the top of the layout. The layout should look like the figure shown.


  37. In the following section titled 'Display the message', items (1), add the code to the DisplayMessageActivity.java file as shown in the figure below. Android Studio will again encounter Cannot resolve symbol errors, so place the cursor on the errors, and press Alt + Enter (or Option + Return on Mac) to resolve the errors.


  38. In the following section titled 'Add up navigation', add the code to the AndroidManifest.xml file as shown below.


  39. Run the app and you are done!
This is only Part 1 of a series of articles on how to effectively use Android Studio for Android programming. It is meant for beginners to Java and Android programming, although experienced programmers are welcomed to it. Part 2 will take the novice even further, so if you are a novice, stay tuned!

Sunday, September 24, 2017

How to Install Oracle Java 8u144 and Android Studio 2.3.3 on a 64-Bit Debian 9.1 Cinnamon (Stretch)

This article is an updated 'how-to' for installing Oracle's Java JDK 8u144 (or SE 8u144) and Google's Android Studio 2.3.3 on a 64-Bit Debian 9.1 Cinnamon (Stretch) PC. If you wish to develop software on the Android platform on your Debian 9.1 Cinnamon PC, then this 'how-to' is for you. Note that most necessary steps are performed at the command line in a terminal – if you are not familiar with this, I suggest reading about it first before trying out this 'how-to'.

Before we start off on our journey, I will assume that you have installed the latest version of Debian – currently at version 9.1 and updated it. Also, note that I will assume that you have installed the proper propriety video drivers for your PC. The URL for this process is here for Nvidia cards and here for AMD/ATI cards. Note that this 'how-to' is based on an Nvidia video card equipped PC, with the propriety video driver installed.

This 'how-to' was tested on the following hardware and found to be working:
  • Gigabyte GA-Z79-HD3 Motherboard
  • Intel Core i5-4590 CPU (3.3 GHz)
  • Kingston 16 Gb DDR3 HyperX RAM
  • NVIDIA GTX 750 Ti PCI-E Graphics Card
You have also set up the PC to give sudo access to the main user. If you have decided NOT to give users sudo access because of security reason, then make sure that you execute 'su -' command for all commands as described from now on – especially before those that have the sudo commands in them.


STEP 1: Install Oracle's Java SE (or JDK) 8


You should also be aware that there is no Java installed on a freshly installed Debian 9.1. This can be verified by executing the following in a terminal:

  java -version

The output is as follows:

  bash: java: command not found

This clearly indicates that Java is not installed by default. We will now install Oracle's Java without having to resort to using a Personal Package Archives (PPA).

So why install Oracle's Java? Why not OpenJDK? Good questions and the answer is that Oracle's Java is recommended by Google. Should you plan to use Java for Android programming, then Google says it is better to use Oracle's version – their Android Studio says that there are stability issues with OpenJDK. Whether this is true is an irrelevant point here – if you do plan to do Android programming later, then install Oracle's Java – else, any Java will do, even OpenJDK.

This article assumes that there is no Java installed on your Debian 9.1 PC. If you had installed other Java previously, then you need to make a decision – keep that Java and install Oracle's Java or remove that Java and install Oracle's Java in its place. That decision is entirely up to you but you need to remember that Google's Android Studio recommends Oracle's Java.


NOTE: If you are using a Debian 9.1 PC with Oracle's Java JDK 8 already installed, except it's an older version, then you need to update it. The update process is covered later in this 'how-to'. Note that if you already have the latest version (8u144) of Oracle's Java JDK 8 already installed, then you can safely skip the part on downloading and installing Java.


You can then proceed to install Oracle's Java by pointing your web browser to here. Be aware that Oracle has upgraded Java to version 9 as shown on the web page (see below). You still can find the correct Oracle JDK 8 to download if you scroll the page down a bit. Then click on the 'Download' button as indicated by the green arrow in the figure below.




NOTE: The version number shown may be higher than this as Oracle is constantly updating Java. The 8u144 version is highly recommended here of course unless you have a specific need for a particular version (scroll down and click on the 'Download' button for the 'Java Archive' if this is the case). In general, always choose the highest version of the JDK to download. Updating will be covered in detail in a later section.


On the next page that appears, you will find an item labeled 'Java SE Development Kit 8u144'. On this item, click on 'Accept License Agreement' as indicated by the green arrow, and followed by a click on the Linux x64 Java download file also as indicated by the green arrow (see figures below). Save the files if a prompt appears – they will go into the 'Downloads' folder by default (unless you have changed this location). Note that the web page image is cropped to accommodate this 'how-to'.



On the same page (you may have to scroll up a bit), you will find an item labeled 'Java SE Development Kit 8u144 Demos and Sample Downloads'. On this item, click on 'Accept License Agreement' (see below), and followed by a click on the Linux x64 Java download file as indicated by the green arrow (see figures below).



Now click the 'Back' button on your web browser and then locate and click on the Java SE 8 Documentation 'Download' button as indicated by the green arrow in the figure below (you may have to scroll up a bit to see this item). This is required in order to download the API documents for Java. This item is strictly not necessary for Android program development but is highly recommended if you are a heavy Java programmer.


On the next page that appears, click on 'Accept License Agreement' as indicated by the green arrow, followed by a click on the document download file also as indicated by the green arrow (see figures below).



If you take a look in the 'Downloads' folder (see below), you should see the following 3 files (if you have downloaded all 3):

  jdk-8u144-linux-x64.tar.gz
  jdk-8u144-linux-x64-demos.tar.gz
  jdk-8u144-docs-all.zip


To install the files, open a terminal and execute the following commands:

  cd Downloads
  tar xzvf jdk-8u144-linux-x64.tar.gz
  tar xzvf jdk-8u144-linux-x64-demos.tar.gz
  unzip jdk-8u144-docs-all.zip -d jdk1.8.0_144

The last two commands in the above are only applicable if you have downloaded the demos and the documentation. The second command above will create a 'jdk1.8.0_144' directory in the Downloads folder while the last two commands above (if applicable) will create the 'sample', 'demo' and 'docs' directories under the 'jdk1.8.0_144' directory in the Downloads folder.


NOTE: Strictly speaking, these 2 items (demos and docs) are not necessary for Android program development but is recommended if you are new to Java and wish to play around with demos and samples provided by Oracle.


Now execute the following commands:

  sudo mkdir /usr/lib/jvm/
  sudo mv jdk1.8.0_144/ /usr/lib/jvm/
  cd ~

The first command will create the '/usr/lib/jvm' directory. The second command will move the whole 'jdk1.8.0_144' directory to '/usr/lib/jvm' – where the root of all Java related files resides. The last command will place you back into your home directory.

Note that you are free to decide where to place the 'jdk1.8.0_144' directory – even your home directory! However the 'jdk1.8.0_144' directory in '/usr/lib/jvm' is highly recommended as this will be in line with other Linux distro's placement of the Java files. This whole article reflects that recommendation.

Notice that the owner and group of the 'jdk1.8.0_144' directory are still in your name and group. You can keep it as it is if you are the only user of the PC or you can set this to root by executing:

  sudo chown -R root:root /usr/lib/jvm/jdk1.8.0_144

The contents of the '/usr/lib/jvm' directory after STEP 1 is completed should be like this:

  drwxr-xr-x 5 root root 4096 Jun 24 14:55 .
  drwxr-xr-x 183 root root 20480 Jun 24 14:06 ..
  drwxr-xr-x 11 root root 4096 Jun 24 14:55 jdk1.8.0_144

Notice that there is only one directory there – the 'jdk1.8.0_144' directory.

The next thing to do is to tell Debian 9.1 where Oracle's Java JDK resides and set up a default Java. For this, we use the 'update-alternatives' command. Execute the following command from the terminal (note that the command is on a single line):

  sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_144/bin/java" 1500 --slave "/usr/share/man/man1/java.1" "java.1" "/usr/lib/jvm/jdk1.8.0_144/man/man1/java.1"

These will install all the necessary links to Oracle's Java, including a slave link for the 'man' pages for Java. After the command has been executed, the default Java was automatically set to Oracle's Java.

To verify that the default Java have been set correctly, you can use the following commands:

  update-alternatives --display java

If the output of the query above contains looks like this:

  java – auto mode
    link best version is /usr/lib/jvm/jdk1.8.0_144/bin/java
    link currently points to /usr/lib/jvm/jdk1.8.0_144/bin/java
    link java is /usr/bin/java
    slave java.1 is /usr/share/man/man1/java.1
  /usr/lib/jvm/jdk1.8.0_144/bin/java – priority 1500
    slave java.1: /usr/lib/jvm/jdk1.8.0_144/man/man1/java.1

then everything has been set correctly. A quick check on the current version of the Oracle's Java can be performed by executing the following command in a terminal:

  java -version

If the output for the command is:

  java version "1.8.0_144"
  Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
  Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

then Oracle JDK 8 has been set up properly.

Now we have to set the environment variables and paths correctly for the whole Debian 9.1 system. Execute the following command:

  sudo nano /etc/bash.bashrc

This will execute the nano text editor and open the '/etc/bash.bashrc' file for editing. Now add (or edit) the following lines at the end of the file.

  export STUDIO_JDK=/usr/lib/jvm/jdk1.8.0_144
  export JDK_HOME=/usr/lib/jvm/jdk1.8.0_144
  export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_144
  export PATH=$PATH:$JAVA_HOME/bin

Save the file and close it. Note that, upon system startup, these will set the STUDIO_JDK, JDK_HOME and JAVA_HOME and PATH environment variables for the whole system. The STUDIO_JDK, JDK_HOME and JAVA_HOME environment variable points to the JDK root while the PATH environment variable will add the '/bin' directory of the JDK to whatever path that has already been specified. Note that these environment variables will be used for Android Studio and other programs which use Java. This also will enable the 'javac' (the Java compiler) command to be executed from any directory. Note that the 'javac' command is not essential to Android software development, but it could prove useful if you are running Java programs from a terminal. It also would be useful if you are new to Java and wish to test software from the command line during the learning process.

Now log out and then log in again to the system in order to make sure that both the environment variables are set. Check that you have correctly set up Oracle Java by executing the commands in a terminal:

  echo $STUDIO_JDK
  echo $JDK_HOME
  echo $JAVA_HOME
  echo $PATH
  java -version
  javac -version

If you see the string 'jdk1.8.0_144' in the output of the above commands, then you have successfully set up Oracle's Java SE 8u144.

Now, whenever Oracle issue an updated version, all you have to do in order to use the new version of Java SE is to follow STEP 1. Just make sure that you change the version number to the new version in the commands shown. However, you do not have to re-create the '/usr/lib/jvm' directory as it already exists. Also, make sure that you remove the links to the old version of Java by using the 'sudo update-alternatives --remove-all java' command before implementing the links to the new version of Java.


STEP 2: Install Google's Android Studio


Before you do anything else you need to remember that you are using the 64-bit version of Debian 9.1, so it is important to note that Android Studio requires some 32-bit libraries in order to run properly. You must install the necessary packages by executing the following command in a terminal:

  sudo apt-get install lib32z1 lib32ncurses5 lib32stdc++6 lib32gcc1 lib32tinfo5 libc6-i386

Note that, if you fail to install these packages, you will not be able to use Android Studio without running into errors.

Now it's time to download and install Google's Android Studio. Point your web browser to here and click on the big green button to start the download.


Then place a checkmark accepting the terms and conditions of Android Studio and then click the download button. Save the file and wait for the download to finish. Meanwhile, the installation instruction for Android Studio will appear on the web page (see below). Note that the instructions are for Ubuntu Linux and can be safely ignored since you are using Debian Linux.


NOTE: On the same web page (you may have to scroll down a bit), under 'Start building apps', you will find an icon labeled 'Build your first app'. You can click on the blue-colored 'Building Your First App' link and bookmark that web page for continuation of this 'how-to'.





NOTE: The downloaded file is named 'android-studio-bundle-162.4069837-linux.zip' and is the currently the latest version of Android Studio (as of September 2017). The version number shown may be higher than this as Google is constantly updating it. As usual, it is highly recommended that you use the latest version.


To install Android Studio, first, start a terminal and then navigate to the Downloads folder. Then execute the following command:

  unzip Downloads/android-studio-ide-162.4069837-linux.zip

The command, as shown above, will decompress the contents of the zip file into a new directory called 'android-studio' in your home directory. You are free to install it to another directory by first changing to that directory and use the 'unzip' command. If you want other users to access Java, then the /opt directory is suggested.

Assuming that you have installed Java in your home directory, you can start the Android Studio set up by executing the following commands on the terminal, one by one:

  cd android-studio/bin
  ./studio.sh

A window similar to the one shown below will appear asking whether you would like to import any settings. If this is the first time you are using Android Studio, it will be likely that you don't have anything to import. Of course, if you had installed Android Studio on Eclipse previously and wish to preserve the settings that were done on Eclipse, feel free to import the previous settings by following the on-screen instructions.


Click on the 'OK' button to proceed. Android Studio will begin loading as shown in the figure below.


After a while, the 'Setup Wizard' window similar to the one shown below, will appear. Click on the 'Next' button to continue.


The next window ('Install Type') similar to the one shown below will appear. The Standard type of setup is already selected – this is recommended unless you want to customize the setup. Click on the 'Next' button and the next window will appear.


The next window (see below) is the 'Verify Settings' window where you will find settings like the setup type, the destination folder, and the Software Development Kit (SDK) components to be downloaded next, plus the total size of the downloads. Click on the 'Next' button and the next window will appear.


If you have Intel's Virtualization Technology enabled in your PC BIOS and Linux kernel, then it will be detected as shown on the wizard's window. You can read up more on this technology at the URL shown on the window. Then click on the 'Finish' button.


The SDK components mentioned in the 'Verify Settings' window will begin downloading as shown below. Wait for the download and installation of the SDK components to finish.


Once downloading and installation is completed, a log window will appear as shown. Note that this log window is where any error messages, if any, will be displayed. Assuming that the log window does not display any error messages, click on the 'Finish' button.


The next window shown is the Android Studio Welcome Screen itself (shown below). You have now successfully installed Android Studio Version 2.3.3 on your Debian 9.1 PC.



NOTE: The latest version of Android Studio 2.3.3 has a new look which differs from the previous versions. One of the major differences is the way Android Studio 2.3.3 handle updates – if there are any, the last line on the IDE window will contain an additional item – the 'Events' item with a green balloon to the left. Click on the 'Events' item, then on the 'update' item (you may have to do this twice) and follow the on-screen instructions if you wish to apply the updates. Note that the update message may also appear in the projects window – as before, click on the 'update' item and follow the on-screen instructions if you wish to apply the updates. Updating will be covered in detail in a later section.


You can now pause and admire your handiwork, then close Android Studio by clicking on the 'x' on the top right-hand corner of the window. Ignore any warnings on the terminal and then close it.

Remember that, at the moment, you have to start a terminal, change to the correct bin directory and then launch 'studio.sh' in order to start Android Studio. Surely there must be an easier way and there is! To place a launcher icon on your desktop, follow the steps outlined below:
  1. Right-click on an empty portion of your desktop and select 'Create a new launcher here...'

  2. A window similar to the one shown below will appear. You can now enter a name for the item – 'Android Studio' seems appropriate here. Then for the command, click on the Browse button and select the 'studio.sh' file in your Home > android-studio > bin directory. In the comment field, enter any text you like – 'Google's Programming IDE for Android' seems appropriate here. Leave the 'Launch in Terminal?' field unchecked.

  3. For the icon, click on the placeholder icon, and navigate to your home directory, double-click on 'android-studio' and 'bin' directories and then select the 'studio.png' file (see figure below). Then click 'OK' to dismiss the 'Launcher Properties' window. A window may pop up asking you whether you want to create a menu item for Android Studio also (see below). Should you say 'Yes', that item will be placed in the 'Other' category.




You can test the launcher on your desktop by double-clicking on it – Android Studio should start up. Then close Android Studio again.

If you had created a menu item, you can also place an Android Studio icon in you Debian 9.1 panel. Click on the 'Menu' and then locate the Android Studio item under the 'Other' category in the menu. Right-click on this item and then select the 'Add to panel' item – then press the 'Esc' key to dismiss the menu. The Android Studio icon will appear in the panel (see below) – single click on this icon to start Android Studio.

If you want to launch Android Studio from anywhere using 'studio.sh' on a command line, it is recommended that the system-wide path include the 'android-studio/bin'. To do this, execute the commands:

  sudo nano /etc/bash.bashrc

In the 'bash.bashrc' file make sure to include the 'android-studio/bin' in the PATH – for example:

  export PATH=$PATH:$HOME/android-studio/bin

If you have already implemented the path to JAVA_HOME (as in STEP 1), then the new line should look like this:

  export PATH=$PATH:$JAVA_HOME/bin:$HOME/android-studio/bin

Save the file and close nano. To make sure that this new path takes effect, log out and then log in again. Now you can launch 'studio.sh' in a terminal from any directory.


STEP 3: Configure SDK Manager


Launch Android Studio again if you have not already done so. Notice the 'Configure' on the last line of the window – click on it and then click on the 'SDK Manager' item (see below).


The 'Default Settings' window similar to the one shown below will appear.


Note that the 'Android SDK' item is automatically selected on the left pane of this window. Other items are listed in the left pane and are available for you to use, but for the time being, keep the selection on the 'Android SDK' only in the left pane.

The column to note is the 'Status' column – it is where the window indicates whether the package has been installed or any updates are available for any package. For the purpose of this 'how-to', a 'package' can include other packages – but this window will only show the 'main' package.

The location of the 'Android SDK' is clearly stated on this window, and you can change its location if you wish – but for the purpose of this 'how-to', keep it as it is.

Note also that the tabs below the SDK location are preselected for the 'SDK Platform'. To change tab, all you need to do is to click that tab – for example, click on the 'SDK Tools' tab, and you will see the contents of that tab (see below).



NOTE: There are lots and lots of SDK tools listed here. Only those tools that are essential to initially build a project have been installed. You are free to install any other extra tools as you so wish.


If you see any items with a minus sign instead of a checkmark and you see the text 'Update Available: xx.x' (where x can be any number), then it is advisable to apply the update immediately.


NOTE: From now on, I suggest that you check if there are any updates by using the Events green balloon or the SDK manager. This should be done every time you start Android Studio.


If you click on the 'SDK Update Sites' tab, you will see URL's for the sites (see below) – do not change anything on this window at this time.


Now click the 'SDK Platform' tab again – keep it at that tab for the moment. Note the 'Show Package Details' box at the bottom of the window – at the moment it is not selected (i.e., no check mark has been placed there). Click on the box to select it – the display will change as shown below.


This display window will show more details on the packages installed so far – including their API level, its revision number and as mentioned previously its status. Note that it even includes packages for the new Android 8.0 (codenamed O or Oreo).

Based on your requirements, you may decide to install more packages – for example, the author has a Google/LG Nexus 5X smartphone running on Android 8.0 (Oreo) – so it was decided to install the additional packages as shown by selecting the box next to its names. Note the 'Download' icons that appear as soon as you select the boxes for the items (see below).



NOTE: If you decide to use the latest Android 8.0, do so as the latest Android version is backward compatible.


You are free to select any packages to download and install, depending on your actual Android devices that you possess. Just select them (you have to scroll down the display for more packages), then click on the 'Apply' button and the 'OK' button on the 'Confirm Change' window that appears next, followed by the 'License Agreement' window (see below). Click on 'Accept', followed by a click on the 'Next' button. The 'Component Installer' window will appear next (see below) and download of the components will start.





NOTE: If you deal with Android TV and/or Android Wear, make sure that you download these items.

The ARM system image more closely matches most Android devices using these processors, but requires the processor to be emulated and is thus very slow. The Intel x86 Atom system image is potentially quite a bit faster, using the Linux's KVM support mechanisms to execute the code in a partially native way. You can try the x86 for speed, and fallback to the ARM if you have compatibility problems.

Support for Google specific Android APIs like the Android Google maps API, are not provided with the standard Android system images. They need to be installed separately using the SDK manager. To use these APIs with an x86 system image you need to also install the Google APIs (x86 System Image) for the same API level.

The difference between a 32-bit and a 64-bit processor is self-evident and can be found easily on the Internet. Examples can be found here or here.



Wait for the download to finish (it may take some time to complete), then click the 'Finish' button (see below).


You will be back at the 'Default Settings' window of the Android SDK (see below). Inspect the packages that were downloaded and installed to make sure that they are correct. If any errors are found – such as downloading errors – then try again. Once this is successful then click the 'OK' button.


You will be back at the welcome screen of Android Studio. Click on 'Configure' again, followed by a click on 'Project Defaults', and finally on the 'Project Structure' item (see below).


On the 'Project Structure' window that appears next (see below), note that Android Studio has been preset to use an embedded Java JDK (the JRE portion). You can continue using this embedded JDK without any problems. However, if you have installed the latest Oracle Java JDK (which you have), you may wish to switch to that instead.


To do that, we first have to clear the box as shown in the figure below. Note that a message will appear at the bottom of the window telling us to 'Please choose a valid JDK directory'.


To select a valid JDK directory, click on the button with three dots (or period) to the right of the field – the screen will change to a directory picker. Navigate to the Java JDK directory as shown below, then click the 'OK' button.



NOTE: On the same screen you will find the field where you can specify the Android NDK (which stands for Native Development Kit) location. Keep this field blank as we are NOT using this feature.


Click the 'Apply' button. If this setting is acceptable to Android Studio, no messages will be shown. Then click on the 'OK' button (see below).



NOTE: If you have updated Oracle's Java, remember to set the JDK location to the new version. Do this if you decide to delete the older Java version from your PC.


You will be back at the welcome screen of Android Studio (see below). Close Android Studio by clicking on the 'x' (as indicated by the green arrow) on the top right hand of this window.



STEP 4: Create a New Project Using Android Studio


Now that you have successfully installed Oracle's Java SE 8u144 and Google's Android Studio 2.3.3, it's time to use Android Studio to develop software for the Android platform. We start off by using Android Studio to write a short and simple 'Hello, world' program, which you can run either on your AVD (Android Virtual Devices), or your actual Android device.

Launch Android Studio if it is closed, then start a new project by clicking on the 'Start a new Android Studio project' item from the welcome screen (see below).


The 'New Project' window as shown below will appear – fill in the details for the 'Application name' to 'Hello World', and 'Company Domain' to 'any.company.com' as shown. The directory in which this project reside can be anywhere on your PC. In the example shown, I have placed the project in my home folder's 'Projects' directory but you are free to use any directory you wish. Then click on the 'Next' button.



NOTE: You can change the package name by clicking on the 'Edit' button on this window – but I suggest that you keep this package name – at least for this 'how-to'. Likewise, you can also enable C++ support by enabling the appropriate box – but for this 'how-to', leave it off.


The 'Target Android Devices' window will appear next (see below). Make sure that the 'Phone and Tablet' item is selected. The 'Minimum SDK' is pre-selected to be 'API 15: Android 4.0.3 (IceCreamSandwich)' and the reason why is as stated in the note below this field. If you are unsure on which minimum SDK to select, you can click on the 'Help me choose' item. For this tutorial, leave it at the pre-selected minimum SDK. Then click on the 'Next' button.


NOTE: If you are developing any projects for Android Wear and/or TV, then select the appropriate buttons. The Android Auto item enables you to add support for it to your existing app. It will enable your app to work on both car and phone screens. Android Auto handles most of the work to adjust each application's user interface to the screen on which it is displayed. Note that to enable your app for Wear/TV/Auto, your app must target Android 5.0 (API level 21) or higher.



The 'Installing Requested Components' (see below) may appear next and this is where Android Studio checks for any components that may be required to be downloaded and installed. Once that is done, click on the 'Next' button.


The 'Add an activity to Mobile' window will appear next (see below). Select the 'Empty Activity' item if it is not pre-selected. Then click on the 'Next' button.



NOTE: There are lots of activities to choose from – you can scroll through the available ones and pick one to suit your app. According to Google, activities are one of the fundamental building blocks of applications on the Android Studio platform. They also serve as the entry point for your interaction with an application and are also central to how a user navigates within an application or between applications. For further reading, go here.


The 'Customize the Activity' window will appear next (see below). Change the 'Activity Name' to MyActivity and the rest of the items below will change as shown. Then click on the 'Finish' button.


NOTE: There are two other radio boxes that you can use – one is labeled 'Generate Layout File' and the other is labeled 'Backwards Compatibility (AppCompat)'. The 'Generate Layout File' allows you to generate an XML file for the activity, while 'Backwards Compatibility (AppCompat)' is letting you know that if you uncheck it, then you'll be including and using the library Activity instead of AppCompatActivity. At the moment, both of these are enabled (i.e., they both have check marks). Leave them enabled for the time being. Use Google to search for more information on these items.



Android Studio (the 'Gradle' part anyway) will then start building the project as shown below. Note that your project is a basic 'Hello world' app that contains some default lines so you do not have to enter those lines into the project. Later you can view the Java source code for this 'Hello world' project in the Android Studio IDE.


After the system has finished indexing, a window similar to the one shown below will appear. If a 'Tip of the Day' window appears (shown below), you can safely close it by clicking on the 'Close' button. You can, if you wish to, also clear the box labeled 'Show Tips on Startup' to disable this feature.




NOTE: For those users who are new to Android Studio (and the IntelliJ) user interface, the various buttons, menu items, tabs, etc, poses a very big challenge – for example, what are the purpose of the various buttons? Do not despair as the Android Studio User Guide is available online here. They will help you to familiarize yourself with the various parts of the IDE. For those who are interested, a guided tour around the IntelliJ IDE user interface (on which the Android Studio is based) is also available here. Take some time to familiarize yourself with the functions of the various components of the IDE. For those of you who are familiar with a programming IDE, you can safely disregard this note and proceed with the 'how-to'.


After a while, the project window will appear (see below). Note that this window shows the source for the package 'MyActivity' Java class. Click on the 'activity_my.xml' tab and the screen as shown below will appear. Note that it does contain a graphic of a Nexus 4 device with the 'Hello World!' text on it. This, however, is NOT the output of the project.



If any error occurs during the project build, Android Studio will display the error message and will offer a 'Tip' to try out ways of solving it.

Notice that the graphics shown is a Nexus 4 device. If this is acceptable to you, then don't change anything. However, since the author has a Nexus 5X device, it was decided to change the graphics to show such a device. This can be achieved by simply clicking on the downward pointing arrow beside 'Nexus 4' (as shown by a green arrow in the figure below), and then selecting 'Nexus 5X' from the drop-down list (see below also). Of course, you are free to choose any other Android device from the list depending on the actual device in your possession. Note that there will be no change in the graphics shown (see below) since the 'Nexus 4' device is similar to that of 'Nexus 5X'.




Now that we have created a new 'Hello World' project, we will test it out to see whether it will run as advertised. Before we do this, we need to create either an emulated Android device or use an actual Android device. We will now proceed to create an emulated Android device for testing the project. Later, this 'how-to' will describe the procedure for running the project on an actual Android device.


STEP 5: Create a New Emulated Android Device


If you have closed Android Studio, launch it again and make sure that the 'Hello World' project is on the screen. Notice in Android Studio's toolbar an icon with the Android logo on it. Hover the cursor over the icon and you will see 'AVD Manager' – that is the icon I am referring to – then click on it (see below). Alternatively, click on 'Tools' in the menu, followed by a click on 'Android' and finally on 'AVD Manager' (see below also).



No matter which path you took to activate the AVD manager, the window will change to 'Your Virtual Devices' as shown below. If you are running Android Studio for the first time, no virtual devices have been set up and the '+ Create Virtual Devices...' button will be shown. Click on that button.


The 'Select Hardware' window will appear next (see below). It already pre-selects the Nexus 5X device with the specifications shown. Note the 3 buttons at the bottom of the screen. The 'Hardware Profile' button allows you to create an Android device other than that in the list. The 'Import Hardware Profiles' allows you to import a profile stored on your computer into Android Studio. The 'Clone Device...' button allows you the clone the currently selected device (the Nexus 5X in this case), and use this as a base for a new device similar to the Nexus 5X. For the time being, do not press any of the 3 buttons – instead just press the 'Next' button to proceed.


The next screen is where you specify the 'System Image' to use for the AVD. Note the message that 'We recommend these Google Play images because this device is compatible with Google Play' on the right. The 'Recommended' tab is already selected and the cursor is already resting on 'O' item (see below). Note that the other item is labeled 'Nougat' and you are required to download this item before use. As mentioned previously, the author has Android 5X device and the system image recommended meets the requirement since that device is running Android 8.0 (Oreo).


Note that there 2 other tabs – the 'x86 Images' and the 'Other Images' tabs. These allow you to select other images to use (you have to download and install some of these before they can be used). Click on the 'x86 Images' tab and you will find the recommended system image here (see below). Make sure that your cursor is on the right item (i.e., O – 26 – x86 – Android 8.0 (Google APIs)). If you are unsure which system image to use, click on the link that says 'API level distribution chart'. A distribution chart will be displayed to guide you with selecting the right image to use. When finished with the chart, click on 'Close' to dismiss the chart window.


If you click on the 'Other Images' tab, you will see a window similar to the one shown below. Note the warning message at the bottom of this window. It says that 'A system image must be selected to continue' – since you have not made a selection yet, you can safely ignore this warning. There is also another warning message (in red color) in the right panel of this window – it reads 'Consider using an x86 system image on an x86 host for better emulation performance' – since you have not made a selection yet, you can safely ignore this warning also.


Now click on the 'Recommended' tab and make sure that your cursor is on the 'O' item, then click on the 'Next' button.

The 'Android Virtual Device (AVD)' window will appear next. Note that you can change (if you wish) some things on the window. For example, if you wish to change the name of the AVD all you have to do is to click anywhere on the field and make the changes. You can also change the AVD device and/or the Android OS by clicking on the 'Change' button. The Startup Orientation is also changeable – portrait or landscape mode. Likewise the Emulated Performance and Device Frame.

You can also click on the 'Show Advanced Settings' button for more settings to set and configure. This button will reveal the Camera (Front and Back), the Network (Speed and Latency), the multi-core CPU, the Memory and Storage, the Custom skin definition, and the Keyboard settings. You can change any of these settings if you so wish.

Verify all the settings – then click on the 'Finish' button.


You will be back at the 'Your Virtual Device' window (see below) with the newly-created AVD listed as shown. From the icons in the 'Actions' column, you can either launch the AVD (using the green arrow), edit any AVD settings (using the 'pencil' icon) and perform any other actions (using the black down arrow) by clicking on any icons in that column. You can also define a new AVD by clicking on the '+ Create Virtual Device...' button. For now, close this window using the 'x' on the top right-hand of the window and you be back at the project window.



STEP 6: Running The Project Using An Emulated Android Device


On the Android Studio project window's toolbar, there will be a green-colored icon that looks like a right pointing arrow (see below). If you hover your cursor over the icon, the words 'Run 'app' (Shift+F10)' will appear below the button.


Click on the icon (or press the Shift+F10 keys) and the 'Select Deployment Target' window will appear (see below). Note the warning message (on a yellow background) stating that 'No USB devices or running emulators detected'. You can safely ignore this message – you have not connected an actual Android device and the emulator has not started yet. Also, note that the Nexus 5X API 26 emulator has been pre-selected by default. If you want, you can set this AVD as the device that will be selected in future by clicking on the box labeled 'Use same selection for future launches'. Note you can also a create a new virtual device by clicking on the appropriate button. Now click on the 'OK' button.


The Nexus 5X AVD will start by displaying a small 'Android Emulator' window, and after a short while, the AVD will appear displaying the 'Google' sign (see below).


After a short animation sequence, the AVD will display the home screen for a while (see below), after which the screen will change to the one shown below. Click on the 'Accept' button on the AVD's screen to continue.



After a short while, the 'Hello World!' words will appear on the AVD's screen (see below). This means that the Nexus 5X AVD is set up correctly and is working perfectly. Note that the 'Hello World!' words will appear at the center of the AVD's screen. This differs from the previous versions of Android Studio where the message was placed at the beginning of the screen.



NOTE: If you see an 'Instant Run applied code changes and restarted the app.' message on a green-colored background on the PC's project window, click on the '(Don't show again)' item to make it go away permanently. Note that this also will be reflected in the 'Event Log' found at the bottom right-hand of the project window.


Note the small vertical window to the right of the AVD (see below). This contains all the controls for the AVD – which includes the power button, the speaker volume controls, the screen rotation controls, the camera button, the search button and the navigation buttons. At the extreme top are the minimize and exit buttons. At the extreme bottom is a row of three horizontal dots – clicking on this will bring up another window (shown below) on which more extended controls are located. You can play with the controls if you wish – when done close this window by clicking on the dot (or period) at the top right-hand of this window. To close the AVD, click on the exit button that looks like an 'x' located on top right-hand of the control window. You will be back at the project screen.




NOTE: The extended controls allow you to set several parameters such as Location (GPS), Cellular network, Battery level, Phone/SMS calls, Directional pad (useful on a tablet), a Microphone device, Fingerprint device, Virtual sensors (accelerometers, etc), Settings, and lastly, Help.


In order to test the Nexus 5X AVD, first, you have to run the project again by clicking on the 'Run' button on the project window. Then 'close' the 'Hello World' project on the AVD. This can be done easily by clicking on the 'Back' icon on the AVD (see below where the icon is indicated by the green arrow) and the screen will change to one as shown below.



This is the 'Home' screen of the Nexus 5X AVD. Users familiar with Android smartphone may be wondering 'where is the app icon?'. Just remember that this the Nexus 5X AVD running Android version 8.0 – it's a bit different from the usual Android where the 'app' icon is present on the home screen. To see all the apps on the AVD, click on (or drag it upwards) on the 'arrow' icon as indicated the green arrow. The apps will be shown on screen (see below). To dismiss this screen, press the Back or Home button. The 'Home' screen will reappear.



Now click on the 'Google Chrome' web browser icon (as indicated by the green arrow below). If your PC is connected to the Internet, you should see a screen similar to the one shown below. This is the welcome screen for Google Chrome – click on the 'ACCEPT & CONTINUE' button to proceed. Next, you will see a sign-in screen – you can either sign-in or decline – that decision is up to you (I clicked on the 'NO THANKS' button).





Next, you will see the Google web page with a search field prominently displayed (see below). Then click on the empty field and, using the on-screen keyboard, type in 'debian' (see below) and press the 'Enter' key on your Debian computer's keyboard (yes, you can use your computer's keyboard as well). Scroll down the AVD's display to see all the possible matches to your search (see below). An example is as shown below (when I clicked on the first item).





To go back to the home screen, press the 'Home' icon (the circular one at the bottom) on the AVD. To close the AVD, click on the 'x' on the vertical panel on the right. You will be back at the 'Projects' window (see below).


You can close the 'Hello World' project any time by clicking on 'File' menu and selecting 'Close Project'. Then you can close Android Studio if you wish. Alternatively, if you want to keep the 'Hello World' project (or any project) in the project window on the next restart of Android Studio, all you need to do is to click on the 'x' on the top right-hand of the project window. You need to confirm this exit by clicking on the 'Exit' button.


STEP 7: Running The Project Using An Actual Android Devicee


We have successfully tested the 'Hello World' project on the AVD emulator. However, our ultimate goal is that the project should run on an actual Android device (a smartphone, for example). In order to do this, you need to connect that device to your development computer (the Debian PC on which Android Studio is currently running) using a proper USB cable and the proper USB ports.

First, you need to enable USB debugging on your Android device. Usually, this setting can found under 'Settings' and 'Developer options' but it can vary from device to device. The newer Android devices with Oreo (Android 8.0) has 'Developer options' under 'Settings' -> 'System'. On some Android devices, 'Developer options' may need to reveal as they are hidden by default. If unsure, consult your 'User's Manual' or the manufacturer's web page for the information on how to enable USB debugging. The screenshot shown below is the already revealed 'Developer options' for the Nexus 5X and show that the USB debugging switch has been set to 'On'. The screenshot below it shows the message that pops up in the smartphone asking you to verify USB debugging by clicking on 'OK'.



If you find an item labeled 'Revoke USB debugging authorizations' on your Android device, select that and clear all previous authorization by selecting 'OK'. Note that if this item is not present on your Android device, you can safely assume that your Debian PC is automatically authorized. The screenshot shown below is the 'Revoke USB debugging authorizations' for the Nexus 5X. Now click the Android device 'Back' button twice to exit the 'Developer options' and the 'Settings'.


Now check if you had previously run/installed the same 'Hello World' application on the Android smartphone. This can be done by pressing the 'App' button on the 'Home' screen of the smartphone (the middle lower button that looks like a round button with two rows of 3 dots on it), and then searching for it on the 'App' screen – delete it if found. Then close the 'App' screen – you should be back at the 'Home' screen.

Next, we have to make sure that the proper USB cable is used. The manufacturers of your Android device usually provide you with one – use that cable and none other. Unfortunately, the author's Nexus 5X smartphone comes only with type C USB connectors at both ends, so it would be impossible to make connections to a Debian PC with type A USB connectors. Should this be the case with your Android smartphone and your Debian PC, it would mean getting another USB cable for the connection between your Android smartphone and your Debian PC. Purchase one with a type A USB connector on one end and a type C USB connector at the other end. Also, consider purchasing a Belkin USB cable – the author did and they proved to be in perfect working order.

You also have to make sure that the USB port to be used on your Debian PC is working. Test this port out first by plugging in a thumb drive (or any other USB device) and if the Debian PC recognizes this device, you can safely say that the USB port is working.

Now make sure that Android Studio is running the 'Hello World' project. Then connect your Android smartphone to your Debian PC using the USB cable. You will note the connection is valid by the figure (as pointed out by the green arrow below) on your Android smartphone Home screen.


Make sure that you have configured the USB connection as 'Transfer files' or 'Transfer photos (PTP)' device (if your device does not support MTP) and not as 'Charge this device' connection. This is easily done by swiping down the round figure on your Home screen (see figure above) on your Android smartphone and selecting the correct USB connection – tap on the 'USB charging this device' item and the figure as shown below should appear on the smartphone. Select 'Transfer files' or 'Transfer photos (PTP)' and the screen should disappear. The figure shows that the 'Transfer files' item was selected as an example. If the file manager (see below) opens on your Debian PC, dismiss it by closing the window.



Then click on the 'Run' button your Debian PC Android Studio's toolbar. As usual, the 'Select Deployment Target' window will pop up as shown below. As suggested by the note (see below) in the 'Connected Device', you will also need to authorize the USB debugging connection to the smartphone with the Debian PC's RSA key by selecting 'OK' on your smartphone (see below). Note that, as soon as you press the 'OK' button on your smartphone, the window on your Debian PC will show the correct device as the connected device. Then, make sure that the 'LGE Nexus 5X (Android 8.0, API 26' item is selected on the 'Select Deployment Target' window on the Debian PC. Then click the 'OK' button to run the project on your Android phone device.




If everything is set up correctly, you should see the 'Hello world!' message displayed on your Android device's screen (see below). If not, see if there are any messages on your Android Studio status screen of your Debian PC. If the message mentions authorization (for example), then, most probably you have forgotten to set USB connection authorization on your device. Do it now and retry running the project again. The important thing to remember here (if unsuccessful) is that Android Studio will display some message and this usually gives you a clue on what is wrong. If you still run into problems, then I suggest searching the Internet for your problem.


You can now close the window on your Android device (usually using the 'Back' key). If you examine the apps on your smartphone, you will find an app labeled 'Hello World' (see below). This is, of course, the 'Hello World' app file (usually with a .apk extension) which Android Studio has downloaded for you. You can delete this file if you so wish. By the way, before you put your Android device aside after testing more new apps developed using Android Studio, remember to disconnect the smartphone first and then switch off USB debugging.


You should see the projects screen on your Debian PC. To close the 'Hello World' project on your Debian PC, click on 'File' and the 'Close Project' menu items on Android Studio. You will be back to the welcome screen and the 'Hello World' project will be listed on the left-hand side pane (see below). To restart (or reload) the same project, make sure that the project is selected and then click on that item (or press the Enter key) – the project will then be started.



Updating Android Studio


If you start Android Studio and see an extra item on the last line, listed as 'Events' (indicated by the green arrow in the figure below), then it is time to apply updates. Below are some example screenshots of this process – these are examples only and may not reflect on what you see on the screen exactly. Note that the update notifications may appear on your welcome screen or your projects window.


Note that there are two types of updates – one is to the Android Studio itself (and indirectly, IntelliJ) and the other is to the SDK. One would require a restart to Android Studio and the other do not. The example shown for the first is an illustration for updating Android Studio 2.3.2 to Android Studio 2.3.3.

If you see the window with the green-colored 'Event' balloon, first click on the 'Events' item followed by a click on the 'update' item as shown below. Sometimes when you click on 'Events', the message shown is maybe too long to display – click on the 'update' item again and the whole message will be displayed.


Then click on the 'Update and Restart' button (see below) and the update process will start. First, the patch file will be downloaded and installed as shown in the figure below. When done, Android Studio will be restarted and the figure below will be shown.




You are done updating Android Studio itself. Notice that the version number shown is 'Version 2.3.3'.

If you see the Android Studio window with the green-colored 'Events' balloon (see below), first click on the 'Events' item followed by a click on the 'update' item as shown below. Sometimes when you click on 'Events', the message shown is maybe too long to display – click on the 'update' item again and the whole message will be displayed.



Then click on the 'Update Now' button (see below) and the update process will start.


First, on the License Agreement window that appears next, click on the 'Accept' button, followed by a click on the 'Next' button. The Component Installer window will appear (see below) and the downloading of the file will start. When completed, the download file will be installed – this will be repeated for all files. Then click the 'Finish' button (see below).




The Android Studio window will reappear with an empty 'Event' balloon denoting that all updates were applied.



Updating Oracle Java


Follow the instructions below in order to update Oracle Java on your Debian PC.
  1. Point your web browser to Oracle's download site and download the files for the latest version of Oracle Java, demos and samples, and finally the documentation. They should be named as 'jdk-XuXXX-windows-x64.exe', 'jdk-XuXXX-windows-x64-demos.zip' and 'jdk-XuXXX-docs-all.zip'. Note the 'X' in the filename can be any number.

  2. Double-click on the '.exe' file and follow the on-screen instructions to install the JDK. Note that the previous version of the Java is still present on your system – just do not delete at this time.

  3. If you have downloaded the demos (and samples) and docs, now would be a good time to install them.

  4. [OPTIONAL] Next, we have to edit the JAVA_HOME system variable and change the version to reflect the correct one. Repeat the procedure to change the 'Path' system variable.

  5. [OPTIONAL] To make the new environment variables effective, log out of the system, then log in again.

  6. You do not have to re-create the '/usr/lib/jvm' directory as it already exists. Also, make sure that you remove the links to the old version of Java by using the 'sudo update-alternatives --remove-all java' command before implementing the links to the new version of Java. Then create a new link to the updated version of Oracle Java, as outlined in STEP 1 above.

  7. If you are using the updated JDK in Android Studio's project structure, make sure that you reset the pointer to it.

  8. You can now delete the previous version of Java JDK.
That's it – you are now using the updated Java.


Summary Of Steps


  • Download and install Oracle's Java JDK (or SE).

  • Download and install Google's Android Studio.

  • Configure SDK for Google's Android Studio.

  • Create a new project on Google's Android Studio.

  • Run the new project on the AVD to test it.

  • Run the same project on an actual Android device.


Final Words:


That's it. You now have a Debian PC which can be used to develop Android software. What was outlined in this 'how-to' is only the 'tip-of-the-iceberg' – there are more, lots more that you need to discover and learn!

If you are an experienced IntelliJ, Android Studio, Java, and Android programmer, enjoy! For those people who are new to Android Studio or Java programming, here are some links which I recommend you visit in order to learn about Android programming.

To learn how to use Android Studio for developing Android software, go here for a tutorial on this. To read the User Guide for Android Studio, go here for this. No matter how experienced you are, I urge you to read this manual.

To learn about the IntelliJ IDE (on which the Android Studio is based), go here for a tutorial on this. Another course the author will recommend can be found here.

If you are new to Java, then I would recommend searching the web for tutorials and the books 'Java For Dummies, 6th Edition' and 'Head First Java, 2nd Edition' as a guide.

If you are new to Java Programming for Android, then I would recommend searching the web for tutorials and the book 'Java Programming For Android For Dummies' as a guide. There is also another book by the same author but is more 'advanced' and is targeted towards Android developers. The title of this book is 'Java Programming For Android Developers For Dummies'.

Happy computing!