Kent Elchuk demystifies the building blocks you need to start building Android apps and submitting them to Google Play.
Take your first steps developing Android apps with the help of Kent Elchuk as he demystifies 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.
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 virtualisation 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 virtualisation 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 ‘ThinkVantage’ which can be pressed after boot to access the BIOS. Look for an option labelled something like ‘Intel VT-x’, ‘Intel Virtualization Technology’, ‘Virtualization 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 virtualisation 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 virtualisation 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 virtualisation. Thus, if you can, add the command below. Otherwise, skip it.
$ sudo apt-get install qemu-kvm libvirt-bin virtinst bridgeutils cpu-check $ sudo kvm-ok If KVM installs properly, the result will show something like the response below: INFO: /dev/kvm exists KVM acceleration 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 libncurses5: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 ./studio.sh
Instantly, you will see Android Studio open and load. From a web developer perspective, 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 application 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 application is to make webviews, which is essentially 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