Linux Format

Android Studio......................

Kent Elchuk demystifie­s the building blocks you need to start building Android apps and submitting them to Google Play.

- Kent Elchuk is an experience­d web developer who has built, secured and maintained many web applicatio­ns for high schools, colleges and web sites.

Take your first steps developing Android apps with the help of Kent Elchuk as he demystifie­s the basics then gets you started building apps and submitting them to Google Play.

You may have an Android device and have downloaded apps for it from Google Play. You may, at some point, have wondered what they are and how they got there. You may even have gone to the next level and asked yourself, “How do I build my own app?”

This article will dispense with the mystery and guide you through the basics and the essentials of building your own Android App. You will learn how to download and install Android Studio (which is free), build an app, test that app on emulators and a real Android device such as a Samsung Note phone, and then upload your app to Google Play so that it can be downloaded by other people.

Although there are various means to build Android apps, this article will use Android Studio, which is the de facto tool to do so and can easily be downloaded from https://developer. Examples of delivered code will be explained using Java, which is typically used to build native apps, and the Ionic Framework, which enables the building of apps with many web technologi­es that web developers use on a daily basis, such as HTML, CSS and JavaScript.

A few packages are required for Android Studio, but they can be installed easily. (The setup we’re using has been tested using the latest 64 bit Ubuntu 16.04 LTS.) Before we show you the two commands to add extra packages, however, you need to have your BIOS virtualisa­tion enabled to be able to use emulators for testing. Without this, you can still create and test apps, but you will need to plug your Android device into a USB port for testing.

Changing your BIOS to allow virtualisa­tion can be done by accessing BIOS Setup at boot-up. On boot, you can normally see a message telling you to use F9, F1, or F10 to access setup. Some PCs have their own dedicated key. For example, older business class Thinkpads, which make excellent Linux laptops, have a key called ‘ThinkVanta­ge’ which can be pressed after boot to access the BIOS. Look for an option labelled something like ‘Intel VT-x’, ‘Intel Virtualiza­tion Technology’, ‘Virtualiza­tion Extensions’, or something similar.

After you enable the BIOS setting, booting up will continue and you will arrive in Linux as usual. But you should now reboot once again to ensure that virtualisa­tion is enabled. Often, it will not work until you perform a fresh boot on a PC for which the setting was changed and saved.

Once your BIOS is good, you can open a terminal in Ubuntu and install KVM. KVM will not install if your virtualisa­tion is not enabled. The command below shows how to install it and check that it works. Again, keep in mind that you can continue if you have issues with KVM or cannot enable virtualisa­tion. Thus, if you can, add the command below. Otherwise, skip it.

$ sudo apt-get install qemu-kvm libvirt-bin virtinst bridgeutil­s cpu-check $ sudo kvm-ok If KVM installs properly, the result will show something like the response below: INFO: /dev/kvm exists KVM accelerati­on can be used

The next two commands will add the packages required by Android Studio that I mentioned a little earlier. If these packages are are not added, Android Studio will not work. $ sudo apt-get install libc6:i386 libncurses­5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386 $ sudo apt-get install mesa-utils

After you have downloaded and unzipped Android Studio, you can move the desired folder to a location where you want it. To make things simple, you can rename the folder to something like ‘android-studio’. To open Android Studio, hit the command line and access the main folder.

For example, this command shows how to access ‘android-studio’ from the current location. $ cd android-studio

Once you’re in the folder, go one level further and access the bin folder and run the command to finally open Android Studio itself. $ cd bin $ sh ./

Instantly, you will see Android Studio open and load. From a web developer perspectiv­e, it is quite a bulky program. Personally, we feel that an SSD hard drive and 4GB of memory are required to make it usable to the extent that you don’t feel trapped in time sinkholes.

To go the extra mile, you can lock Android Studio to your launcher, create a launcher image to start the program or make it a startup program when you launch Ubuntu. Keep in mid that your Linux flavour will have custom methods to make the program behave as you want.

Using Android Studio

Once you launch Android Studio for the first time, you can create a new applicatio­n using default templates or using a prepared package. For example, you may have bought a book about Android recipes and so you have some downloaded files to use as a starting point.

The next section will explain how to build your app based on a premade set of code – basically a folder with files.

Premade Android apps

One project included with this applicatio­n is to make webviews, which is essentiall­y loading a website once someone clicks on an app icon.

To get started, click through File > Import Project > Select Project > Select Folder then click OK and OK again. After you do that, you will see that Android Studio builds a Gradle Project – Gradle being a build tool.

If something fails, you will see an error message in the messages window shown on the bottom. You can install the required build tools by clicking the link in the messages window. After each update, you simple click Finish, which is very obvious.

Once the Gradle build is completed, you may be prompted to upgrade Gradle to the latest version; you may opt to do so or skip this step.

After the project is loaded into Android, you will see the

 ??  ??
 ??  ??
 ??  ??
 ??  ?? The blank screen when you use a premade app for the first time. There are a few critical files that need reworking to make it your own.
The blank screen when you use a premade app for the first time. There are a few critical files that need reworking to make it your own.

Newspapers in English

Newspapers from Australia