Thursday, July 23, 2015

How To Install Oracle Java and Android Studio on a 64-Bit PCLinuxOS KDE


NOTE

This article is an updated ‘how-to’ from my previous article on Oracle’s Java SE and Google’s Android Studio on PCLinuxOS64 KDE. It also expands the article to include information on Android Studio’s SDK Manager and AVD Manager, and more importantly, how to get Virtualization Technology to work with PCLinuxOS64 KDE. It was designed to make things easier for the reader to find information in one place – this blog.




This article is a ‘how-to’ for installing Oracle’s JDK 8 (or SE 8) and Google’s Android Studio on a 64-bit PCLinuxOS64 KDE. If you wish to develop software on the Android platform on your PCLinuxOS64 KDE 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’.


STEP 1: Check for Virtualization Technology

First you need to check whether you have Virtualization Technology (Intel or AMD based) on your PC. Why is this important? In a word, the answer is ‘speed’. If you have used Google’s Android Development Tools (ADT) previously on the Eclipse IDE previously, then you know what I mean. Basically speaking, Virtualization Technology allows you to create an Android Virtual Device (AVD) which loads and run faster than previously – thus cutting software development time. The Virtualization Technology employed by Google’s Android Studio depends on both hardware and software – the hardware side is dependant on whether you are using a hardware-virtualization capable CPU on your PC, while the software side is dependant on whether your OS has drivers for the hardware-virtualization capable CPU on your PC. Working together, these technologies will provide you (the user of the PC) with time-saving features while developing Android software.

To test whether the CPU in your PC is hardware virtualization capable, run the following command in a root terminal:

  egrep --color=auto ‘vmx|svm|0xc0f’ /proc/cpuinfo

If your PC support Virtualization Technology, then you should see either ‘vmx’, ‘svm’ or ‘0xc0f’ highlighted in color in the outputs (repeated according to the number of cores in your CPU). On the other hand, if nothing highlighted is displayed, then your processor does not support hardware virtualization, and you will not be able to use Virtualization Technology. This means that you cannot use the Intel Atom x86 AVD and emulation is purely on a software level (very, very slow!) with Android Studio.

To check whether the CPU on your PC is manufactured by Intel or AMD, execute the following command in a root terminal:

  lscpu

You should various information on your CPU being listed out – the two most important pieces of information are:

  Vendor ID:       GenuineIntel OR AuthenticAMD
  Virtualization:  VT-x OR AMD-V


These will tell you whether you are using an Intel or AMD CPU and whether the CPU support hardware virtualization – in the case of my PC, it’s an Intel CPU with virtualization capability.

If you have a Intel CPU based PC which is hardware virtualization capable, then do a restart of your PC and enter the BIOS (classic or UEFI) – the settings for Virtualization Technology are usually found under the Advanced CPU (or Processor) setting named ‘Intel Virtualization Technology’, ‘Intel VT-x’, ‘Virtualization Extensions’, ‘Vanderpool’, or something similar. Check whether the option is enabled – enable it if was not and then select ‘Save and Exit’ or the equivalent feature to save your settings changes and reboot your computer.

If you have an AMD CPU based PC which is hardware virtualization capable, then do a restart of your PC and enter the BIOS (classic or UEFI) – the settings for Virtualization Technology are usually found under the Advanced CPU (or Processor) setting named ‘Secure Virtual Machine Mode’, or something similar. Check whether the option is enabled – enable it if was not and then select ‘Save and Exit’ or the equivalent feature to save your settings changes and reboot your computer.

Next you need to make sure that the Linux Kernel-based Virtual Machine (KVM) module is loaded and ‘/dev/kvm’ is present on your PC. Usually the absence of these items are made known when trying to run an AVD (Android Virtual Device) using the Intel Atom x86 CPU/ABI – the error message when trying to launch such an AVD will clearly indicate this.

To check whether the KVM module is loaded, open a root terminal and execute the following commands (one by one). Note that you should replace the correct module name in the second command according to the manufacturer of the CPU:

  lsmod | grep kvm
  lsmod | grep kvm_intel
    (OR)
  lsmod | grep kvm_amd


If these command does not return anything, then the modules are not loaded. To load these, execute the following:

  modprobe kvm
  modprobe kvm_intel
    (OR)
  modprobe kvm_amd


These command should not return anything. To verify that the modules has been successfully loaded, execute the following command again:

  lsmod | grep kvm

If you should see something similar to the one shown below, then the modules have been successfully loaded. Of course, the numbers would be different on your PC.

  kvm_intel       121810 0
  kvm             252560 1 kvm_intel
    (OR)
  kvm             252560 1 kvm_amd


To check whether ‘/dev/kvm’ is present on your PC, execute the following command:

  ls -la /dev/kvm

If you seen the following output:

  crw-rw----+ 1 root root 10, 232 Jul 20 10:40 /dev/kvm

then you can proceed to the next step. However, if you are unable to load the KVM modules, then it is quite possible that KVM is not part of your Linux kernel. You may have to resort to re-building your kernel – this ‘how-to’ will not cover that topic. Consult the Internet for instructions on how to do this.

Also note that the modules are only loaded for this session. If the PC is shut down and then re-started again later, the process of manually loading the KVM modules has to be done once again. To load the modules automatically upon every start-up of the PC, you need to add both lines (‘/sbin/modprobe kvm’ AND ‘/sbin/modprobe kvm_intel’ or ‘/sbin/modprobe kvm_amd’ depending on the manufacturer of your CPU) to the ‘/etc/rc.d/rc.local’ file using a root terminal and your text editor. Just remember to save the file and restart your PC to test it. If successful, the modules should show up as being loaded upon start-up.


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

On a newly-installed and updated PCLinuxOS64, only Oracle’s Java Runtime Environment 8 is installed by default. This can be easily verified by executing the following command from a terminal:

  ls -la /usr/lib/jvm

The output will display a screen similar to the one shown below.


Note that only Oracle’s JRE version 1.8.0.51 (the latest version as of July 21st 2015) is installed. Also note that other Java directories exists – from version 1.6.0.38 onward but they are mostly empty. From my experience and as far as I know, PCLinuxOS64 is the only Linux distribution that currently install Oracle’s Java – although they still label it as Sun’s Java. Google’s Android Studio, however, requires the full Java SE, and the recommended version is Oracle’s Java (JDK or SE 7 and above). So, you need to install it first before you proceed.

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 a moot point here – if you do plan to do Android programming later, then install Oracle’s Java – else, any Java will do, even the default Oracle JRE 8 or OpenJDK.

To install Oracle’s Java SE 8, first open the Synaptic Packet Manager and then click on the ‘Search’ button. Another window will pop up, and by entering ‘java-1.8.0’ in the text field and pressing the ‘Search’ button, Synaptic will display all entries for ‘java-1.8.0’. The display is similar to the one shown below:


Notice the entry for Java SE 8 which is labelled ‘java-1.8.0-sun-devel’. Mark this for installation by clicking on the check box to the left of the item and selecting the ‘Mark For Installation’. Then click on the ‘Apply’ button. Click on ‘Apply’ again to confirm and the package will be downloaded and installed. Close Synaptic when done.

Then take a look at the ‘/usr/lib/jvm’ directory again – it should look like the screen shown below:


Note the differences – in addition to the previous JRE links there are now new ‘java’ and ‘java-sun’ links. If you dive into the ‘java-1.8.0-sun-1.8.0.51’ directory you will now find a ‘bin’ directory in addition to the old ‘jre’ directory. If you execute the following command:

  update-alternatives --display java

you should get an output similar to the one shown below:


As a last check to verify that Oracle’s Java SE 8 has been installed correctly, execute the following command:

  java -version

If you see an output similar to the one below, then Oracle’s Java SE 8 is correctly installed and you can proceed with the next step.

  java version "1.8.0_51"
  Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
  Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)


STEP 3: Install Google’s Android Studio

To download and install Google’s Android Studio, point your browser to here and click on the big green button, agree to the terms, and then click the download button. Wait for the download to finish and then start a normal (NOT root) terminal and execute the following command from your home directory:

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

This will decompress the contents of the zip file downloaded into a new sub-directory called ‘android-studio’ in your home directory. To start Android Studio setup, execute the following commands, 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. However, if you are moving from an older version of Android Studio, you may want to keep any settings made previously – in this case specify the location of the settings and let the setup wizard do the job.


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


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 – this is recommended unless you want to customize the setup. Click on the ‘Next’ button and the the next screen will appear.


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 – just remember that the web page there is for Windows only – to read more on Linux and Virtualization Technology, click here. Then click on the ‘Next’ button.

The next screen that appears as shown below is where you agree to accept the license for installing Google’s Android SDK. Note that this is a must and cannot be skipped if you want to develop software for the Android platform. Click on ‘Accept’ and then the ‘Finish’ button.


The SDK components will begin downloading as shown in the screen below.


Once downloading and installation is completed, a log window will appear as shown. This log window should NOT show any error messages – for example, the Android virtual device failed to be created – which is an indication that hardware virtualization is not supported on your PC. Click on the ‘Finish’ button to finish with the Setup Wizard.


The next screen shown is the Android Studio IDE itself (shown below). You have now successfully installed Android Studio on your PCLinuxOS64 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 and skip the next three paragraphs.


If there are any updates, a window similar to the one shown below will pop-up.


Click on the ‘Update and Restart’ button. Android Studio will close and the updates will begin downloading as shown.


Once the updates have been installed, Android Studio will start again.

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.

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 New’ and then ‘Link to Application...
  2. A window similar to the one shown below, will appear. Under the ‘General’ tab, change the ‘Link to Application’ text to ‘Android Studio’.

  3. Click on the ‘Application’ tab and in the description field enter ‘Android Studio’. In the comment field enter ‘Google’s Programming IDE for Android’. To set the command field, first click on the ‘Browse...’ button, navigate to the ‘android-studio/bin’ sub-directory in your home directory and select the ‘studio.sh’ file. In the work path field set it to your home directory using the folder button to the right of this field. Leave the other fields blank and click on the ‘OK’ button.

You will find an icon labeled ‘Android Studio’ on the desktop. To set a proper graphics for the icon, right-click on the icon and select ‘Properties’. Click on the icon, then select ‘Other icons:’ in the window that pops up. Click on the ‘Browse’ button and navigate to the ‘android-studio/bin’ directory and select ‘idea.png’ file. Click ‘Open’ and the Android Studio icon will be set properly – click ‘OK’. The desktop will now look something like the figure below.



You can test the launcher by clicking on it. If everything works properly, Android Studio will launch and the IDE will appear on your desktop.


STEP 4: Configure SDK Manager

On the Welcome Screen and under ‘Quick Start’ of the Android Studio, click on ‘Configure’ and the ‘SDK Manager’ item. The SDK Manager (as shown below) will start 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. Take note that, depending on the number of packages that requires updating, the whole process of downloading and installing the packages will take time – so be patient. Once the packages has been installed, a window may pop-up saying that the SDK Manager has been updated and Android Studio needs to be restarted for the updates to take effect – do so as per the request.


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 M – the latest Android version (API 22) 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 smart phone running Android version 4.4.2 (KitKat), so the packages marked as shown below, was selected to be installed. The ‘Install 6 packages...’ button was then clicked upon and the packages were downloaded and installed. Do not close the SDK Manager yet.






STEP 5: Configure 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 an AVD called ‘Nexus_5_API_22_x86’ has already been defined by Google. As the name suggest, this is for the Nexus 5 Android smart phone and you can view it’s settings by selecting the AVD and clicking on the ‘Edit’ button. The window as shown below will appear. Take special note of the warning that appears as the last line in this window.


Make a note of each of the settings as this provide a guide for setting up an AVD of your own later. Close the ‘Edit’ window when done and you will be back in the AVD Manager window. 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 later.


For now, let’s take a look at the pre-defined Nexus 5 AVD. To start an AVD, make sure that you click on the ‘Android Virtual Devices’ tab, select the AVD that you want to start (just the Nexus 5 AVD in this case), and then 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 will appear (see below). If, for some reason, the loading was slow and/or errors occurred, it is possible that hardware virtualization plus Linux’s KVM (Kernel-based Virtual Machine) features are NOT supported in your PC. This will often happen if your PC is NOT using the newer version of an x86 compatible CPU – for example your PC is using an very old AMD CPU. It also can happen if you don’t have Virtualization Technology enabled in BIOS and you are using Intel Atom x86 CPU/ABI in your AVD. Alternatively, the KVM module is NOT loaded into your Linux kernel.


The error message on the KVM module not being loaded may look like the one shown below. If you see this you may want to make sure that Linux’s KVM module is loaded before trying to run the AVD.


Another possible error message may look like the one shown below. This is due to one of the CPU features being missing – SSSE3 (Supplemental Streaming SIMD Extensions 3) in this case. This can happen if your CPU is an older model AMD CPU. Note that even if this error message is shown, the AVD will still load but errors may occur during it’s usage. You will be made aware of this by error messages popping up about Google Play Store and Maps being stopped during running of the AVD.


Assuming that there were no errors during launching, the Nexus 5 AVD will be displayed as shown below. If this is the first time you are starting an AVD, a window (as shown below) will also appear. This is a thank you from Google and the setting for the usage statistic to be sent to Google. You can either accept or decline (by clearing the check mark) and then click on the ‘Proceed’ button. Meanwhile, the Nexus 5 AVD will be loading and will display the flashing ‘android’ sign.



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


As with an actual Android smart phone, you need to unlock the phone before you can use it (ignore any messages about backup). Click on the padlock icon on the AVD and swipe (move the cursor) upwards to unlock the device. The screen will change to one shown below.


Click on the ‘OK’ button and the main home page of the phone will appear (see below).


Click on the ‘Apps’ button (the center icon at bottom) and the screen will change to one as shown below.


Click on the ‘OK’ button and all the application software that were included with the AVD will be shown (see below).


To test out an example software, 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 ‘pclinuxos’ (see below).


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


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


You can now play around with the Nexus 5 AVD – notice how fast the response is, thanks to 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 6: Setting Up 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, 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 smart phone 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 the 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 smart phone is using the ARM processor, I decided to use the ‘ARM (armeabi-v7a)’ CPU/ABI as I will be testing software on that smart phone 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 web-cam 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 web-cam on your PC. The RAM size 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 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 – at a very much slower rate than the Nexus 5 AVD! First, the screen shown below will 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 very slow to respond to clicks as compared to the Nexus 5 AVD. 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 x86 compatible 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, select it and 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 – at a very much faster rate than previously. This illustrate the power of using the Intel Atom (x86) CPU/ABI together with a capable Intel x86 compatible CPU and 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 and the SDK Manager (use the ‘x’ on the top right hand of the window). Use the ‘Back’ key on the Android Studio window to go back to the main page.


STEP 7: Create a New Project Using Android Studio

Now that you have successfully installed Oracle’s Java SE and Google’s Android Studio and set up an AVD, 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 and dismiss any tip screen if it appears (by clicking on the ‘Close’ button). 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’ 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. The next screen may look like the one shown below – if not skip to the next paragraph. Note the ‘Rendering Problem’ message which states that ‘Rendering failed with a known bug. Please try a rebuild.’ Click on the ‘rebuild’ item, and wait a while for the renderer to rebuild.


After the renderer has finished building, 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 tool-bar 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). Make sure that the Nexus 5 AVD is selected.


Click on the ‘OK’ button and the AVD will start and the screen will change to the one shown below.


Unlock the AVD (like a regular Android smart phone) to run the project and 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.


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.


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 smart phone, 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 (see 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 labeled ‘Revoke USB debugging authorization’ 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 one pops up (see below). You may need to authorize the USB connection to the smart phone for debugging with the PC’s RSA key by selecting ‘OK’ on your smart phone (see below also).



Then click on the ‘Run’ button in Android Studio’s tool-bar. 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 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 – 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 PCLinuxOS64 KDE 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!