Convinced that Android development is for you? What you need then is a complete development environment so that you can jump in and get started. With that in mind, this post will go over the basic steps necessary to prepare your computer for Android development. By the end, you’ll be ready to start inputting code and testing your apps!
Downloading the files
Remember: in order for you to code in Java on your machine, you’re first going to need to download the Java Development Kit. You can find that here – what you’re looking for is the ‘Java SE Development Kit’. Simply make sure you pick the right version and the right installation file for your operating system and your processor (most likely x64).
You can likewise get Android Studio here. Again, get the latest version and remember that this is also going to include the Android SDK and various other tools you need to get started.
It doesn’t really matter what order you install these elements in, but it does make sense to go ahead with Java first seeing as nothing else will work without it. To get started, just double click on the JDK executable and then click ‘Next’ to go through the steps. Make a note of where the JDK is installed, as this may come in handy in future.
Installing Android Studio is just as simple. Once again, just run the setup file and then click ‘Next’ to progress through the stages. Make sure you tick the checkbox that indicates that you wish to install the Android SDK as well as Studio and once again, it can be a good idea to make a note of where everything is being installed in case you need it later. By default, your app might go into the AppData\Local which is a hidden folder and can cause confusion later on. If you change this to something easier to find though, note that your directory isn’t allowed to have any spaces in it.
This installation process might feel a little like a lengthy and fiddly process. But don’t worry: now that you’ve done this once, you’ll actually never need to do it again (at least until you swap computers). And when you compare this to what the set-up process for Android development used to be like… there’s really no comparison. Android Studio has come on leaps and bounds since the early days and that’s fantastic news because it makes the whole process much more accessible than it previously was.
Welcome to Android Studio: Starting your first project
And with that… you’re in! Load up Android Studio and it should all be working right out of the box. Again, there was a time that you had to tell Android Studio where the JDK and Android SDK were located but thankfully it now does that automatically.
So, all that’s left to do is to try out your first project!
1 Naming the app
To do that, just click the top menu and select File > New > New Project. You’’ now be asked to come up with a name for your application and you’ll be prompted to add a company domain as well. The ‘package name’ (the name of your app as the devices will see it) is then made up of both these names.
So, if you want to call your app ‘Ultimate Calculator’ and your business domain is ‘Apps Forever.com’, then you might end up with a package name like com.appsforever.ultimatecalculator. The only name that the user will see though, is ‘Ultimate Calculator’.
2 Targeting the right Android version
Next, you’ll be asked what kind of device you’re developing for. The ‘Minimum SDK’ is the lowest version of Android that you want to support. By default, at the time of writing, this is set to 4.0.3 IceCreamSandwich.
We’ll talk more about this later on. For now, know that the lower the Minimum SDK, the more users will be able to try and buy your apps. However, if you wish to use more modern features of Android, then you might be required to target newer versions of Android exclusively.
When you downloaded Android Studio and your version of the Android SDK, you will likely have installed the most recent and up-to-date version. Android SDKs are backward compatible, so you can support any version of Android that is lower, but you’ll need to update it if you want to support something newer in future.
For now, just leave this as it is and of course, you’ll want to tick ‘phone and tablet’. If you wanted to target watches or TV, then you would tick the respective boxes below.
3 Choosing an activity type
On the next screen, you can choose to add an activity. Apps are made up of activities which generally speaking are the screens that you move between while using your app. While you can add activities later on, chances are you’re going to begin your app with some kind of splash screen or UI to show to the user, so you may as well add an activity at this stage.
There are several options here though, which include ‘Basic Activity’, ‘Bottom Navigation Activity’, ‘Empty Activity’ etc.
Basic Activities are your default applications. These are the apps that have most of the general recommended UI elements in place such as the FAB. The FAB is the ‘Floating Action Button’ – a round button that lives in the bottom right corner of many apps on the Play Store (including nearly every app from Google). If you want to follow Google’s design language (Material Design) in future, then go ahead and choose Basic Activity. This does introduce more code for us to deal with though, so for now I recommend you stick with ‘Empty Activity’.
4 Naming your activity
Click ‘Next’ again and you’ll now be on a screen where you can name your activity and the accompanying ‘layout file’ which will handle the appearance of your app and the positions of the elements. Activity files are written in Java and so they have the extension ‘.java’ while layout files use XML and so have the ‘.xml’ extension. If you build a big app project, then you can eventually end up with lots of different activities, all with different names. This can get confusing and so it’s important to name them logically. If no activity in your app is considered the ‘main’ screen, then you might want to change this and name it something different.
Your layout file is going to go into your resources folder, along with images and sound effects that you create later on. A good thing to learn right now is that anything in this folder is required to use lower case only. That’s why the default name for your xml is activity_main.xml, while the default name for your Java file is ‘MainActivity.java’. MainActivity.java is getting around the lack of spaces by using something called ‘camel case’ where each new word starts with a capital. Because we can’t use capitals in resource files either, they need to use underscores to separate individual words.
But for now, you can leave these names as the defaults. Just hit ‘Next’. Do that and you’ll now be looking at your very first app – congrats!
In fact, Google has already populated this project with some code for you so it should already function as a full ‘Hello World’ app! Were you able to run it (which requires a little more set-up unfortunately!) then you would see ‘Hello World!’ displayed on your screen. For now though, if you double click on the activity_main.xml file and then choose the 'Design' view, you'll be able to see what it would look like.
But there are actually a whole lot of different files that contribute to just that single ‘Hello World!’ and there are an awful lot of buttons and tools that are probably already starting to give you nightmares.
Don’t worry, it’s all quite simple once you know what you’re doing. In the next post, we’ll demystify Android Studio so you’re ready to start bending it to your will and building your own apps!