Get Started with Android App Development

Get Started with Android App Development

New developers find it very easy to get started with Android App Development. All the tools and documents are easily available on the internet for free. This is a simple guide which will help just get started and ignite that spark which will full fill your desire to become a professional android app developer.

What Will You Learn?

  1. What tools to use to develop apps for Android.
  2. Create, Build and Deploy a simple Android app.
  3. Learn how to test an app on an Emulator on your computer.
  4. Learn how to test an app on an Android mobile.

Why Android?

Android is one of the most popular os for smart phones. The major reason is the company behind it, Google. From the day one, the OS was open for any one to use and develop apps. The ease of app submission process is the major reason it has been adopted by almost all the app developers across the world. It doesn't involves app review process making the life of app developer's easier.

Machine Requirements

Although you can get started with Android development on a 4 GB RAM laptop, it is highly recommended that you use a minimum of 8GB RAM machine. And if you are about to buy a new machine then go for minimum 16 GB RAM machine. If you are planning to use Emulators then 16GB is a minimum which I can suggest.

I would highly recommend to use Mac for your app development if possible. The reason is very simple. iOS and Android are the top 2 mobile os in the market. On a Mac you can develop for both iOS and Android. If you are planning only android and your budget doesnt permits Mac then you can go for Windows machine. Still I will recommend not to compromise on the RAM.

Environment Setup

Now that you have the infrastructure in place, time to setup your environment for app development.

Android Studio

The official tool for developing app for Android is Android Studio. It is Integerated Development Environment build upon Intellij Idea. Earlier Google was using Eclipse with an External Plugin which was available for download from Android website. But then Google made Android Studio as it official tool for Android App Development.

You can download Android Studio from the below link.

developer.android.com/studio

Once you are done with downloading the installer for Android Studio, you can run it to start the installation process. Make sure that you have active internet connection through out the environment setup process.

The whole install process is wizard based. Make sure you take your time while choosing the options and going through the wizard. As the wizard keeps on changing no use explaining much here as it will get outdated in no time.

Android SDK Manager

There is a separate sdk for each and every version of android released. If you have installed the app just now then you might be having the latest sdk by default. If not you better install the sdk for atleast 2 versions.

  1. The Latest Android Version.
  2. The Android Version on your Test Mobile.

To install the sdk you can open the SDK manager by going to the menu Tools>SDK Manager.

android-get-started-sdk-manager

AVD Manager

Once you are done with the above process, you can go ahead and create AVDs (Android Virtual Device). These are the Emulators on which you can test your app on your computer itself.

To open the AVD lists, goto menu Tools>AVD Manager:

android-get-started-avd-manager

Now click on the Create Virtual Device button.

android-get-started-device-definition

Choose Phone as the category and select the Phone Pofile which you want to set. Once it is done click on next.

Now you will need to select the system profile.

android-get-started-system-profile

Just select the release version which you want to set for the emulator. I would recommend choosing the latest stable version available. Normally it will be on top. Once done click on next.

android-get-started-avd-name

Set the Name. You can leave everything else as default. Click on Finish. You are done.

android-get-started-avd-created

Now you are ready to get started with Anroid App Development.

What Language to use to Get Started with Android App Development, Java or Kotlin?

This is a very important question which will confuse any new android app developer. First let me tell you a brief history about Android.

Android was started as a company which made OS for Smart Cameras. It had used Java for its development. At that time Sun Micro Systems were the owners of Java. Google has used Java for most of its development after it took over Android.

Sun Microsystem was aquired by Oracle. It meant that all the rights for Java with Sun Microsystem was also transferred to Oracle. Google became skeptical of using Java for its development as Oracle was having full control on Java.

Thus in recent years Google started its search for languages that can replace Java both on Client and Server side. Now Google is promoting Kotlin as official language for Android App Development.

Kotlin being a newer language is certainly better than Java. Although Java is evolving but many apects of Kotlin makes it a better choice. But Java cannot be ignored completely as of now considering that many apps and library are already developed on Java.

Keeping this in view Android Studio is developed in such a way that you can have both Java and Kotlin in your app. It is highly recommended if you are developing a new app then develop it in Kotlin, as it is here to stay.

If you want to learn Kotlin as a language then you can checkout its official website.

kotlinlang.org

Android Project

Lets get started with Android app development in Android Studio by creating a project.

Welcome Dialog

When you open the Android Studio you get a welcome dialog which shows you the recent projects which you have worked on. It also shows you several links on the right side.

android-get-started-welcome-dialog

If you have installed Android Studio for the first time then the left section will be blank.

Create Android Project Dialog

To create a new project click on "Start a new Android Studio Project" link. You will get the Create New Project dialog as below.

android-get-started-create-new-project-dialog

You will need to set the following parameters. Once done click on next.

  1. Application Name.
  2. Company Domain : This will be used in setting the package name.
  3. Project Location.
  4. Include C++ Support : This is used to develop usin android native libraries.
  5. Include Kotlin Support : Ensure that you select this checkbox if you want to develop usng Kotlin.

Target Android Devices

Once you click on next in the prvious dialog you are shwn the Target Android Devices dialog. Here you choose the form factors and minimum sdk.

android-get-started-target-device-dialog

Activity Templates

The next dialog in the project creation wizard asks you to choose an activity template so that android studio can generate some codes and layout for the project.

android-get-started-add-activity

You can choose Basic Activity. It has most of the basic stuff you need for now.

Activity Configuration

Next you will need to set the Name, the layout File name and Title.

android-get-started-configure-activity

Workspace

After the project is created the Android Studio first look will be something similar to the following.

android-get-started-workspace

Android Studio Basics

Now that you have the project created, let me walk you through the minimal features of Android Studio which you will need to get started.

Project Tab

This is the tab on the left side of inside Android Studio. It will show you all the files and resources for the project.

android-get-started-project-tab

As you can see it is divided into 2 sections:

  1. app
    1. manifests: It has the configurations for activities and the application.
    2. Java : The source files for the app. Mostly ".java" files or ".kt"
    3. res : It will contain all resource files to support the app such as images, design xml for the activities. There are other type of assets file which I will take up when explaining some advance topics other articles.
  2. Gradle Scripts : These are the build scripts for the the app and the libraries to be imported.

Activity Design Tab

When you select an xml file for an activity then you will get the following tab.

android-get-started-activity-design

You can design most of the activity layout in the design tab. It comprises of the following sub tabs:

  1. Pallette: It contains the different components which can be dragged on to the activity layout file.
  2. Attributes: Here you can customise the parameters as per your need. In your learning period you will not be doing much stuff out here.
  3. Text Tab: This will contain the raw xml corresponding to the design of the activity. It is for advance android developers. Infact many professional developers prefer to use this tab instead of the main design tab. It gives them more control.

Source Code Tab

When you open any source file it will open up the following tab.

android-get-started-source-code

This is where you can write your Kotlin or Java codes. All the logics for your app will be added here.

There are many more tabs and features in Android Studio which are very useful. We will not discuss that here as it will be overwhelming for now.

Running the Project

Now that you know the basic usage of Android Studio, you can try to run the simple application which you have added.

To do that you just need to click on the Run button in the top tool bar. There are other ways of doing it, but for now you can use this button.

android-get-started-run-the-project

Running your App on AVD

Once you click on the button you will be shown a dialog where you can select your emulator or the AVD.

android-get-started-emulators-for-running-app

You can see the AVD which you created earlier. Select your AVD and click on OK.

You might be shown the following popup. Just select Proceed without Instant Run.

android-get-started-instant-run-warning

You will see lot of logging activities in the logcat tab. There will also be a message saying Gradle Build. Once the build is over the AVD will be starting and running your app.

android-get-started-app-running-on-avd

So you have now run your first android app.

Running your App on an Android Device

Now it is time to run your app on an actual Android device. Setup your device as follows:

  1. Connect you mobile to your machine using a USB cable.
  2. If you are running on Windows you might have to install drivers for your mobiles if it doesnt detects you phone.
  3. Enable USB Debugging in the Developer Options in your Mobile. Here are the steps to enable USB debugging:
    1. Goto the Settings menu.
    2. For Android 8 and higher Goto System menu.
    3. Goto About Phone menu.
    4. Tap on Build Number 7 times. It will show a toast message that Developer Options is enabled.
    5. Return to previous menu.
    6. Goto Developer Options menu near the bottom.
      1. Enable USB Debugging.
  4. Now click on the Run button on the tool bar in the Android Studio.
  5. In the Select Deployment Target dialog, select your device and click on ok.
    • android-get-started-select-target-device
  6. Android Studio will build and install your app on the mobile. You will see the Hello World message on your screen.

android-get-started-app-running-on-device

Sample Projects

Android Studio has lot of sample projects which will help you get started with Android App Development.

Here are the steps to follow to import the Andoid Code Samples.

  1. Close all the projects.
  2. Open the Welcome Dialog of Android Studio.
    • android-get-started-welcome-dialog-import-samples
  3. Click on Import an Android code sample link.
  4. It will show you Browse Sample dialog.
    • android-get-started-browse-samples-dialog
  5. Selec the Sample which you want to play with and click on Next button.
  6. It will bring up a Project Configuration dialog.
  7. Just select the default values and click on next.
  8. It will start downloading and building the sample app.
    • android-get-started-downloading-samples
  9. It might take some time depending on your internet speed.
  10. Once done the projec will open in your workspace.

Conclusion

So now you have started your journey to become an Android App Developer. In this article you learned about Android Studio. You also learnt how to create, build and deploy android apps to an emulator. You also learnt how to deploy to a real android mobile. And now you can also play around with the sample code projects.

It is time for you to get your hands dirty and learn more and more about android.

Checkout other articles on Android App Development. If you are stuck up somewhere just comment below and I will try to help you out. Also do share this article with your friends. It will motivate me to write more articles for you.

Did you find this article valuable?

Support Neeraj Jaiswal by becoming a sponsor. Any amount is appreciated!