Setting up Android Studio

Setting up the development environment – so that you can create Android applications – can take a quite a long time.  However, it is similar to downloading and installing any piece of software, in that most of the time is just waiting.

 

Java

The first thing to do is to download the Java (which is the programming language used on the Android platform).  You might think that you already have Java and be tempted to skip this step, but there are two main types: the type that nearly every one has that lets you run Java programs, and the type that most people do not have that lets you make Java programs.  It’s safer to follow this step unless you have written Java programs before and know that you have a JDK installed.

  • The version changes all the time, but if you visit the Java SE Development Kit download page then it should point you to the lastest version.
  • Click on the Java download link.  Look for words such as Java Platform and JDK.

It can be confusing because there are so many different versions, but you should end up seeing something similar to that shown below:

screenshot taken from oracle website

Choices for installing the Java Development Kit

  • Select the option to accept the licence agreement.
  • Click on the download link for the platform that you’re using (e.g. Windows).
  • Download the file and then follow the instructions to install it.

 

Android Studio

Now it’s time for Android Studio.  This is classed as an Integrated Development Environment (IDE), which just means that it should include all the tools that you need wrapped up in an easy to use interface.

  • Visit Android developer website: https://developer.android.com/sdk/index.html
  • Download Android studio (currently 1.1GB) and follow the instructions to install.  Since you installed Java first, it should be found automatically.

The first time that you run the software the Android Studio Setup Wizard will download any updates that it needs, which again can take a bit of time.  Eventually though you’ll see the startup screen that means everything is ready:

Android start up screen

Android start up screen

 

Creating a New Project

Android Studio includes a number of templates that do most of the setup work for you.  Most of the articles on this site will use the Empty Activity as a starting point – which is just the bare minimum needed to run an Android app.

  • Click to Start a new Android Studio project
  • Most of the settings can be left as default, or are self explanatory (e.g. project name), but Company Domain can be a bit confusing.  Essentially it wants you to enter your company’s website address, but it won’t check that the site actually exists (or that you own it).  It isn’t important unless you are planning on putting your app in the Android store.
  • When you see a collection of example screens, choose the Empty Activity option

When you have entered all of the details, the software will start to create your app.

  • Look for a progress bar at the bottom of the window – wait until it completes

 

Finding Your Way Around

The two important files will probably have been opened automatically (note, names can change depending on what you enter, but the file types are what is important):

  • activity_main.xml: The visual design of the app
  • MainActivity.java: The code for the app

If you accidentally close them, then you can find them in the Project area (left-hand edge of Android Studio), and open them by double-clicking.

Where to find the important files

Where to find the important files: MainActivity (in the Java folder), and activity_main.xml (in the layout folder).

 

The first thing that you should do is check that everything is working OK; which you can do by running the app.

  • Click on the play button, which you’ll find around the top-middle of Android Studio:
Where to find the 'play' button (green arrow)

Where to find the ‘play’ button (green arrow)

 

After a few seconds the Device Chooser will open.  Don’t panic about the “Nothing to show” message – we haven’t started any emulators yet (these are versions of Android devices that can run on your computer).  An emulator should have been created during startup, and the option to launch the emulator should now have been selected.

  • Click OK

It will take a while for the emulator to start, and the app to install, but eventually you should see Hello World!  The emulator behaves just like a phone, so you can use the back button to exit the app.

 

A Note on the Visual Editor

It’s possible that when you view the activity_main.xml file, you’ll see a message about a rendering problem.  This seems to just be a problem in Android Studio, and does not affect the app itself.  To remove the erro, just switch the theme to something else.

  • Click on the AppTheme button just above the preview window.
  • Choose a different theme, such as Holo Light, and see if the message goes away.
Issue with rendering preview

Issue with rendering preview



Comments are closed.