Environment Setup

1. Download Android Studio

Since the end result of reading this book is to create Android applications, you will download the official Integrated Development Environment (IDE), Android Studio, used to develop Android applications. Here is the link to download Android Studio: https://developer.android.com/studio/index.html

Click on the ‘Download Android Studio’ button as shown below:

image alt text

Accept terms and conditions and based on your machine, the correct download link will be displayed.image alt textFor MAC you will see ‘DOWNLOAD ANDROID STUDIO FOR MAC’ mentioned as shown in the above picture.

While it is downloading, you will also be shown the page on this link: https://developer.android.com/studio/install.html

Watch the video to help you understand a few basic steps to be executed after download. The same page also has links to learning resources. "Learn with Udacity" is a resource you can consider in the future.

Since we are interested in learning Java first, we will leave the rest of the videos to much later in the book.

Invoke Android Studio and open the application. You will be prompted with several screens as shown below. Just press ‘Next’ on each of the screens and then select ‘Finish’ in the last

image alt textimage alt textimage alt text

Once you hit finish in the last screen the app will start downloading the necessary files as shown in the screen below.

image alt text

2. Create a basic Android Project

We will now create a basic Android project by invoking Android studio and selecting the default options in almost all the screens as shown in the screenshots below:

  1. In this step use the default of ‘Start a new Android Studio Project’

  2. In this step change the default folder ‘MyApplication’ to ‘Tutorial’ and leave the default options for the rest of the selection.

image alt text

  1. Follow the defaults all the way through till the ‘Finish’ button

image alt text On the above screen you will leave the default 'Phone and Tablet' checked. However if you are developing your program for a Android Wearable device or a TV or Car (Auto) or Internet of Things then you would select the other options.

You will learn more on the API level in the last chapter. For now you will leave the defaults alone.

image alt text

In the above screen also you will keep the default 'Empty Activity' selected. With this default, the IDE creates a basic Activity class and its associated files. You will learn more on Activity in the last chapter.

image alt text

The last step will start downloading the needed components from the Internet and the below screen is shown.

image alt text

After all components are downloaded, gradle will start building the project and opens up the MainActivity Java class in the editor from the project which was just created.

image alt text

image alt text

Note in the above step, gradle may show an error due to missing sdk's. And sdk is an acronym for Software Development Kit. These errors show up because by default Android Studio does not download all the sdk's and libraries that you might need. Every version of Android has its own sdk. Every emulator that you create has its own set of libraries that you need to download. Android Studio typically gives us a link to download the missing software. Click on the blue link which will show the next screen. Choose ‘Accept’ for the license and then the downloads of the missing software begins.

image alt text

Once you accept, Android studio will download and opens the MainActivity class as shown below. Wait till gradle finishes its build to see if there are any more errors.

image alt text

3. Setting up a Java Project Library

Now we will create a Java library project by invoking File→ New → New Module and in the next screen choose Java Library as shown in the screenshots below

image alt text

image alt text

image alt text

image alt text

Now add the main method to your ‘Tutorial’ Java class by typing in the below method

Public static void main(String[] args){

System.out.println("hello")

}

Refer figure below

image alt text

Now it is time finally to run our Tutorial program!!

There are two ways to run this program.

  1. Select Tutorial on the left navigation and then select ‘Run (Tutorial.main())

  2. Be inside the class on the right page and right click with your mouse and select ‘Run (Tutorial.main()). Both the screenshots are shown below

image alt text

image alt text

The first time you invoke the program, gradle will take a while to show the output. But when you make changes and run it again, it will take lesser time. If all went well, you should see the word "hello" in the output as shown in the figure above.

Congratulations!! You have come a long way in this setup. You downloaded Android Studio; setup a Java library module and created a Java class called ‘Tutorial’ and added the main method to print out "hello" on the screen.

Are you wondering what all these jargons are? In the next lesson you will learn what is a Java class, what is a method and what are println statements.

results matching ""

    No results matching ""