Friday, January 15, 2016

How to Install Oracle Java 8u66 and Android Studio 1.5 on a 64-Bit Linux Mint 17.3 (Rosa)


NOTE

This article updates the previous blog on Java and Android Studio on Linux Mint 17.1 (Rebecca). Oracle's Java is now at version 66 and Google's Android Studio is now at version 1.5.1. This is in addition to Linux Mint which is now at version 17.3 (codename Rosa). Due to these changes, I have decided to update this article.



This article is a ‘how-to’ for installing Oracle’s Java JDK 8 (or SE 8) and Google’s Android Studio on a Linux Mint 17.3 Cinnamon (Rosa) PC. If you wish to develop software on the Android platform on your Mint 17.3 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’.

I will assume that you are using a freshly installed Linux Mint 17.3 – if not, you have to make sure that any already-installed software is not using OpenJDK Java. Also, make sure that you apply any new updates to Linux Mint 17.3.


STEP 1: Set Libre Office from Using OpenJDK

Click on ‘Menu’ > ‘Office’ > ‘Libre Office’. Libre Office will open. Click on ‘Tools’ > ‘Options...’. Click ‘Advanced’ and de-select ‘Use a Java runtime environment’ and click ‘OK’. Close Libre Office.


STEP 2: Remove OpenJDK JRE’s From Linux Mint 17.3

On a newly-installed and updated Linux Mint 17.3, only OpenJDK JRE (Java Runtime Environment) 7 is installed by default. Google’s Android Studio, however, requires the full Java JDK, and the recommended version is Oracle’s Java (JDK or SE 7 and above). So, the first thing to do is to delete the OpenJDK 7 JRE and install Oracle's Java JDK 8 in it's place.

If you launch the Firefox browser now, and type ‘about:plugins’ in the location (URL) bar, it will show that ‘IcedTea-Web Plugin (using IcedTea-Web 1.5 (1.5-1ubuntu1))’ is one of the plugins installed. It will not be possible to remove this plugin using Firefox’s add-ons tool as this plugin was installed by OpenJDK itself. So we have to turn to the Synaptic Packet Manager to do the job. Make sure that Firefox is closed, then launch Synaptic and enter ‘icedtea’ into the search box (do not use the Quick Filter). Then mark the following items for complete removal:

  icedtea-7-jre-jamvm
  icedtea-7-plugin (+icedtea-plugin)
  icedtea-netx
  icedtea-netx-common
  openjdk-7-jre (+default-jre,libatk-wrapper-java,libatk-wrapper-java-jni)
  openjdk-7-jre-headless (+ca-certificate-java,default-jre-headless)
  openjdk-7-jre-lib

(Note: those preceeded by '+' are to be marked for removal also)

Click the ‘Apply’ button to remove the marked files, then close Synaptic. You can then check whether the Firefox Java plugin has been removed by launching Firefox again and typing ‘about:plugins’ in the location (URL) bar. The resulting display should indicate that there is no Java plugin present now. Then close Firefox again.


STEP 3: Install Oracle’s Java SE (or JDK) 8

Point your web browser to the Oracle SE download page here and download the latest version of the 64-bit JDK (not Server JRE or the JRE) – currently at version 8u66 (or 1.8.0_66). It is also recommended that you download the API documents, demos and samples for the JDK – although this is not required for Android development on Android Studio. Once the packages have been downloaded, execute the following commands:

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

The last two commands in the above is only applicable if you have downloaded the demos and the documentation. The second command above will create a ‘jdk1.8.0_66’ 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_66’ directory in the Downloads folder.

Now execute the following commands:

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

This will first create the /usr/lib/jvm/ directory then move the whole ‘jdk1.8.0_66’ directory to that directory – where the root of all Java-related files resides. The last command will place you back into your home directory.

Notice that the owner and group of the ‘jdk1.8.0_66’ directory is 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_66


STEP 4: Set the System's Environment Variables and Paths

Now we have to set the environment variables and paths correctly for the whole Linux Mint 17.3 system. Execute the following command:

  sudo nano /etc/profile

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

  export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_66
  export PATH=$PATH:$JAVA_HOME/bin

Save the file and close it. Note that, upon system startup, these will set the JAVA_HOME and PATH environment variables for the whole system. The 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. This 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 installed Oracle Java by executing the commands (one by one) in a terminal:

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

If you see the string ‘jdk1.8.0_66’ in the output to the above commands, then you have successfully removed OpenJDK 7 JRE and replaced it with Oracle’s SE 8.

Now whenever Oracle issue an updated Java version, all you have to do in order to use the new version of Java SE is to follow STEP 3 and STEP 4 above. Just make sure that you change the version number to the new version in the commands shown above. However, you do not have to re-create the ‘/usr/lib/jvm’ directory as it already exist.


STEP 5: Install 32-Bit Libraries

Since you are using the 64-bit version of Linux Mint 17.3, run the following commands in a terminal to download and install some necessary 32-bit libraries:

  sudo dpkg --add-architecture i386
  sudo apt-get update
  sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0

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


STEP 6: Install Google's Android Studio

Point your browser to here and click on the big green button and then agree to the terms. Click on the download button and wait for the download to finish. Then start a terminal and execute the following command:

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

This will decompress the contents of the zip file downloaded into a new directory called ‘android-studio’ which can be found in your home directory. To start Android Studio setup, execute the following commands, one by one:

  cd android-studio/bin
  ./studio.sh

Ignore any warning messages on the terminal. A window 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 – so just click on ‘OK’.


Android Studio will begin loading.


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


The next screen similar to the one shown below will appear. The Standard type of setup is already selected. Click on the ‘Next’ button and the the next screen will appear.


The next screen that appears (see below) is the Verify Settings screen. If you accept the current settings, click ‘Next’, else click on ‘Previous’ and make changes.


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


The next screen that appears as shown below is where Android Studio will begin downloading components from the Internet and installing them. Wait for it to complete.


Once downloading and installation is completed, a log window will appear as shown. Assuming that the log window does not display any error messages, click on the ‘Finish’ button.


The next screen shown is the Android Studio Welcome Screen itself (shown below). You have now successfully installed Android Studio on your Linux Mint 17.3 PC.


Notice the ‘Check for updates now' on the last line of the window – click on ‘Check’ and if you already have the latest version, a window similar to the one shown below will pop-up. Click on the ‘Close’ button.



If there are any updates, a screen similar to the one shown below, will appear. Click on the ‘Update Now’ button and the process of downloading and applying the updates will begin (see below) – wait for the process to finish and then click the ‘Finish’ button on the ‘SDK Quickfix Installation’ window (see below).




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. From now on, you should make it a habit to check for any updates to Android Studio (by clicking on ‘Check’) every time you launch it. Ignore any warnings on the terminal and 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. To create an easier way to launch Android Studio and 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...’. A window similar to the one shown below, will appear.


  2. 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. For the icon, click on the rocket icon, and navigate to your home directory, double-click on android-studio and bin directories and then select the ‘studio.png’ file. The final figure will look similar to that shown below.


  3. Then click ‘OK’ button. A window (see below) may pop up asking you whether you want to create a menu item for Android Studio also. Should you say ‘Yes’, that item will be placed in the ‘Other’ category on Linux Mint's menu. The Android Studio launcher icon should appear on your desktop (see below also).



You can test the launcher on your desktop by double-clicking on it – Android Studio should start up. If you had created a menu item, you can also place an Android Studio icon in you Linux Mint panel. Locate the Android Studio item under the ‘Other’ category in your menu, right-click on this item and then select the ‘Add to panel’ item. The Android Studio icon will then appear in the panel – 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 this command in a terminal:

  sudo nano /etc/profile

In the 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 3), 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 7: Configure SDK Manager

Start Android Studio (if not already started) and you may see the main studio window with a message on the top right hand corner stating a new version of it is available. You can view more details on these updates by clicking on the ‘available’ link followed by clicking in the ‘More Info...’ button on the window that appears next.



On the ‘Quick Start’ screen of Android Studio, click on ‘Configure’ and followed by the ‘SDK Manager’ item. The Default Settings window of the Android SDK will appear as shown below. This is where you can check or set the Android SDK location. Also it is where you can do a check on what SDK Platforms and SDK Tools packages were already installed.


Click on ‘Launch Standalone SDK Manager’ and it will start (see below) and if there are any update packages, it will be shown on the ‘Install xx packages...’ button (where xx = number of update packages).


Click on that button, and the ‘Choose Packages to Install’ window will appear as shown below. Click ‘Accept License’ for all the items followed by a click on the ‘Install’ button.


The SDK Manager window will re-appear and the packages will be downloaded and installed as shown below. Wait for this process to finish.


Now it's time to check what has been installed so far. On the SDK Manager window all installed packages are marked ‘Installed’ under the ‘Status’ column. Note that SDK packages has already been installed for Android 6.0 Marshmallow (API 23) – the latest Android version from Google. Other packages may have already been installed – just check the ‘Status’ column.

Depending on what Android devices that you wish to develop software for, you may wish to install additional packages for that device. For example, the author has an Android smartphone running Android version 4.4.2 (KitKat), so the packages marked as shown below, was selected to be installed. The ‘Install xx packages...’ button was then clicked upon and the packages were downloaded and installed. Ignore any warnings on a pop up log window – just close the window. Do not close the SDK Manager yet.






STEP 8: Starting the AVD Manager

Click on ‘Tools’ and ‘Manage AVDs...’ from the Android SDK Manager menu and the Android Virtual Device (AVD) Manager window similar to the one shown below will appear.


Notice that there is no AVD's defined by default. This differs from previous versions of Android Studio where Google supplied one pre-defined AVD called ‘Nexus_5_API_22_x86’. For some reason or other, it was removed from the list of AVD's supplied. Note that if you had installed a previous version of Android Studio and updated it to the latest version, this pre-defined AVD will be removed. Since all the AVD creation tools are supplied, it will be easy to recreate this AVD – but for this article we will ignore this AVD and continue with creating an AVD to correspond to your actual Android device.

Notice that there is another tab labeled ‘Device Definitions’. Clicking on this tab will show a window similar to the one below and they contain a list of generic AVD device definitions. You can use this list as a starting point for creating your own AVD. Note that the majority of the devices listed are by Google – although you can find some generic devices at the end of the list (sorted by screen sizes).


STEP 9: Creating An AVD

If you have an Android device that is listed in ‘Device Definitions’, all you need to do in order to create an AVD, is to select that device from the list (the Nexus 5 is used as an example here as indicated in the figure below), and then click on the ‘Create AVD...’ button. For those that do not have an Android device that is listed, skip this step and go to STEP 9 directly.


A screen similar to the one shown in the figure below, will appear. Note that the ‘AVD Name’ and the ‘Device’ will contain the pre-defined entry – do not edit or change these. The ‘Target’ entry will depend on the SDK packages installed and the lowest entry will be selected – in this case Android 4.4.2. You can change this if you like. Then refer to the specifications of the Nexus 5 and enter the required information into the fields. The final entries (using the Nexus 5 example) will look something like the figure below.



Click the ‘OK’ button to create the new Nexus 5 AVD. A log window will appear (see below) informing you of all the settings for the newly-defined AVD. Note that any error messages will also appear in this window – in this case, there are none. Click on the ‘OK’ button to dismiss the window.


You will be back in the AVD Manager window with the newly created Nexus 5 AVD already selected (see below).


Click on the ‘Start’ button. A window labeled ‘Launch Options’ (shown below) will appear.


Click on the ‘Launch’ button to launch the AVD. A ‘Starting Android Emulator’ window (shown below) will appear. Any error messages that occured during launching of the AVD will be displayed in this window.


Next, the Nexus 5 AVD will be displayed as shown below. Note the flashing ‘android’ sign in the middle if the display.


Once the AVD has finished loading without any errors, the Nexus 5 AVD will appear (see below). That was fast, wasn’t it? This is only possible with Intel’s Virtualization Technology using Intel Atom x86 CPU/ABI in your AVD plus Linux’s KVM feature and with the PC’s BIOS set up correctly to use this technology.


Click on 'GOT IT' on the welcome sign and the Nexus 5 home screen will appear (shown below)


To test the AVD, click on the ‘Apps’ button (the center icon at bottom) and the screen will change to one as shown below.


To test out an sample app, click on the ‘Browser’ icon – if your PC is connected to to the internet, you should see a screen similar to the one shown below. Note the query below which ask you whether you want to share your location – if so, click on ‘Share location’, else click on ‘Decline’. If you had clicked on ‘Share location’, the screen will change to look like the one shown below.



Type something into the Google search box, using the on-AVD-screen keyboard – for example ‘debian’ (see below).


Then click on the search icon. The page shown below will appear.


Click on the ‘Debian’ (first item shown) that appears on the AVD’s screen. If everything works, the Debian home page will appear (see below).


You can now play around with the Nexus 5 AVD – notice how fast the responses are, thanks to Intel’s Virtualization Technology plus Linux’s KVM features. You can safely close the AVD by clicking on the ‘x’ on the top right hand of the window. You will then be back to the AVD Manager window.



STEP 10: Creating Your Own AVD

If, for some reason or other, the Android device that you possess is not listed under the ‘Device Definitions’ tab of the AVD Manager, you can create one to correspond to your device. First make sure that you have selected the ‘Device Definitions’ tab (see below), then click on the ‘Create Device...’ button. You should see a screen similar to the one shown below.



Now make sure that you have all the details for your Android device ready – search for it on the Internet or use your User’s Manual if the details are present in there. As an example, the author has entered the details for his Samsung Galaxy Note 2 in the figure below, then clicked on the ‘Create Device’ button.


You will be back to the AVD Manager window with the ‘Device Definitions’ tab selected. Notice that the device you created will be in the device list (and selected by default). The screen will look like the one shown below.


Note that you have only created a definition for the device but NOT an AVD for that device. To create an AVD, select the newly created device (if it is not already selected), then click on the ‘Create AVD’ button. You will see a screen similar to the one below. Notice that the ‘AVD Name’, the ‘Device’, and the ‘Target’ entries have been pre-entered from the new device definitions.


You can edit the entries mentioned above if you so wish, but for this tutorial, leave those entries alone. Note however, a warning message that no CPU/ABI system image has been selected yet will appear at the bottom of the window – do so now by clicking on the down-arrow to the right of the CPU/ABI item on the window and select the CPU as per your device specification. Since my Android smartphone is using the ARM processor, I decided to use the ‘ARM (armeabi-v7a)’ CPU/ABI as I will be testing software on that smartphone itself (more about this later). The ‘Hardware keyboard present’ item was also deselected. Notice that the warning message has now changed to ‘No skin selected’. Change the skin to ‘No skin’ by clicking on the down arrow on the Skin item and selecting ‘No skin’ from the list. The screen will now look like this.


If you have a webcam on your PC, you can use it as your rear camera and/or your front camera. Click on the down-arrow on the ‘Back Camera’ and/or ‘Front Camera’ and select ‘Webcam0’ for the entries. You can safely skip these items or use ‘Emulated’ for both items if you do not have a webcam on your PC. The ‘RAM’, ‘VM Heap’ and ‘Internal Storage’ sizes was pre-selected – you can change this if you wish. Also, if you wish to have a SD card on your AVD, specify the size of this card – I have entered 200 as an example here. To make the AVD perform faster, the use of the host GPU is highly recommended – I have enabled this in the screen shown below.


Click the ‘OK’ button to create the new AVD. A log window will appear (see below) informing you of all the settings for the newly-defined AVD. Note that any error messages will also appear in this window – in this case, there are none. Click on the ‘OK’ button to dismiss the window.


You will be back in the AVD Manager window with the Android Virtual Devices tab and with the newly created AVD already selected (see below).


To start this AVD, click on the ‘Start...’ button then click the ‘Launch’ button on the Launch Options window that appears next (see below).


The AVD will now load – be patient as it will take time for the image to appear! When it does appear, it will first appear with a flashing ‘android’ sign in the middle of the display.



After a long while, the screen will change as shown below.


Click the ‘OK’ button and the screen will change as shown below.


You can go ahead to play around with this device. Just note that it is quite slow to respond to clicks. You can safely close this AVD by clicking on the ‘x’ on the top right hand of the window. You will then be back to the AVD Manager window.

If your PC is using an Intel CPU and you have set up your BIOS accordingly, you can edit the AVD (by clicking on the ‘Edit...’ button) for the newly-created device and change the CPU/ABI to the ‘Intel Atom (x86)’, then click the ‘OK’ button twice to re-create the AVD (see below).



To start the AVD, click on the AVD to select it, then click on the ‘Start...’ button. Click the ‘Launch’ button on the Launch Options window that appears next. The AVD will now load – at a very much faster rate than previously. Unlock the AVD when it has finished loading and you will see the home screen as shown below.

The speed at which the AVD loads illustrate the power of using the Intel Atom (x86) CPU/ABI together with a capable Intel CPU and Intel’s Virtualization Technology plus Linux’s KVM features with Android Studio on your development PC! Just remember that the hardware virtualization feature only works on x86 compatible CPU's. Also remember that older CPU's (Intel or AMD) may also not work with these hardware virtualization features. If you are unsure about your CPU's ability to support hardware virtualization, search the internet for help.






Close the AVD when you have finished playing around with it. Then close the AVD Manager (use Alt-F4 or ESC key to close the AVD Manager because of a bug – there are no minimize, maximize and close keys shown on the top right hand of the window) and the SDK Manager (use the ‘x’ on the top right hand of the window). Use the ‘Back’ key on Android Studio to go back to the main page.


STEP 11: Create a New Project Using Android Studio

Now that you have successfully installed Oracle’s Java SE 8u66 and Google’s Android Studio 1.5 and set up an AVD of your own, 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, 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’ screen as shown below will appear – fill in the details for the ‘Application name’ to 'Hello World', and ‘Company Domain’ to 'anycompany.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/Android’ directory but you are free to use any directory you wish. Then click on the ‘Next’ button.


The ‘Target Android Devices’ screen 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.


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


The ‘Customize the Activity’ screen 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.


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 the Java source code for this ‘Hello world’ project in the Android Studio IDE.


When completed, Android Studio will display it’s main IDE screen (see below). If a ‘Tip of the Day’ window appears (also shown below), you can safely close it by clicking on the ‘Close’ button. If this is the first time you are using Android Studio, the next screen will take some time to appear while the system will carry out indexing of the IDE – the word ‘Indexing...’ will appear in the bottom of the IDE window (see below).


After the system has finished indexing, a screen similar to the one 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 on your AVD.


To run this project on your AVD emulator that you have created, click on the ‘Run’ button (the one in Android Studio’s toolbar that looks like a green-colored right pointing arrow) and the ‘Choose Device’ screen (see below) will appear. Note that the ‘Launch emulator’ item has been selected and that you don't have any other running device (‘Nothing to show’ will be present in the top half of the window).


Select the Nexus 5 AVD, then click on the ‘OK’ button and the AVD will start and the screen will change to the one shown below. After a while, the ‘Hello world!’ output will appear on the AVD (see below).



After admiring your handiwork, close the AVD and you will be back at Android Studio (see below). Notice that you are now viewing the contents of the ‘activity_my.xml’ tab. For the time being, just ignore any messages shown in the status area at the bottom of the Android Studio’s screen, and the area where the Nexus 4 device reside previously (click on ‘Clear cache’ to clear these messages and restore the previous screen).


To view the Java source code for this project, just click on the ‘MyActivity.java’ tab and the screen will change to the one shown below.


Switch back to the ‘activity_my.xml’ tab and run the project again but this time, select the Samsung Galaxy Note 2 AVD instead (see below). Then click on the ‘OK’ button.


The screen will change to one shown below.


Unlock the AVD and and you will see the ‘Hello world!’ output on the AVD’s screen. Close the AVD after you are done.



STEP 12: Setting Up The Target Android Device

We have successfully tested the ‘Hello World’ project on the AVD emulators. 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 our development PC (the 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 device. Usually this setting can found under ‘Settings’ and ‘Developer options’ but it can vary from device to device (indicated by the green arrow below). On some Android devices, ‘Developer options’ may need to revealed 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.


If you find an item labelled ‘Revoke USB debugging authorization’ (see below) 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 PC is automatically authorized.


Next we have to make sure that the proper USB cable is used. The manufacturer of your Android device usually provide you with one – use that cable and none other. You also have to make sure that the USB port to be used on your PC is working. Test this port out first by plugging in a thumb drive (or any other USB device) and if the PC recognize 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 device to your PC using the USB cable. Dismiss any file manager window on your PC if any pops up (see below – you may have to do this several times – also ignore any warning messages that may also pop up). You may need to authorize the USB connection to the smartphone for debugging with the PC’s RSA key by selecting ‘OK’ on your smartphone (see below).



Then click on the ‘Run’ button in Android Studio’s toolbar. As usual, the ‘Choose Device’ window will pop up as shown below. Note that the ‘Choose a running device’ item is selected and that device is listed as shown (a Samsung GT-N7100 in this case). Click the ‘OK’ button to run the project on your Android 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 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 note 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 with your problem.


You can now close the window on your Android device (usually using the 'Back' key). If you examine the apps on your device, you will find an app labelled ‘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 – just note that if you run the same project again without first deleting this .apk file, a warning will appear asking you whether you would like to delete the old .apk file before it is actually run (see below also). By the way, before you put your Android device aside after testing more new apps developed using Android Studio, remember to switch off USB debugging first.



To close the ‘Hello World’ project on your 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 under the ‘Recent Projects’ column (see below). To restart (or reload) the same project, make sure that the project is selected under ‘Recent Projects’ and then double-click the item (or click on the ‘Open an existing Android Studio project’ item, then select your project file) – that project will then be started.




Final Words:

That's it. You now have a 64-Bit Debian 8.2 Cinnamon PC which can be used to develop Android software. If you are an experienced Intellij, Android Studio, Java and Android programmer, enjoy! For those people who is 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 about the Intellij IDE (on which the Android Studio is based), visit https://www.jetbrains.com/idea/documentation/ for a tutorial on this.

To learn how to use Android Studio for developing Android software, visit https://developer.android.com/training/index.html for a tutorial on this.

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!

No comments:

Post a Comment