How to get started with Android App Development
Do you want to learn android app development? If Yes, but you do not know how to get started then this article will help you to get started with Android App Development. At the end of this article, I will be providing some links where you can get more information about Android Apps and how to develop basic Android Apps.
This tutorial has been prepared for beginners to help them understand basic Android Programming.
So, let’s get started.
The first question that arises in our mind is that on which language android apps are written?
Android apps can be written in different languages such as Java, Kotlin, C++ etc. So, this is up to you with which language you want to start your Android journey.
Prerequisites for learning Android App Development:
- Choose your language and get familiar with the language you want to start Android App development. (* this tutorial is based on Java)
- Familiarity with the right development tools and environment.
- Knowledge of android components.
- Knowledge of basics of Architecture of Android Development.
So before getting started let’s talk about the fundamentals of Android Apps:
- Android Apps are a combination of different UI components.
- Android is an open-source and Linux based operating system for mobile devices.
- It is a unified approach that means you have to develop Android Apps for Android and your application will be able to run on a different device powered by Android.
Setting Up Environment:
- Download Java (you must install JDK and JRE both, but you don’t have to worry as they are combined).
- Install Android Studio or Eclipse or IntelliJ (I prefer android studio because it provides you with a lot of tools to work with).
Below are the steps to download java and Android Studio
Downloading Java:
Link: https://www.java.com/en/download/
Image reference: https://www.java.com/en/download/
After Downloading java setup environment variables
Setting Up Manually:
- Search env on windows
- open edit the system environment variables
- under advanced options select environment variables
- under user select path
- click on edit
- under path open new and add your java path there
- Click on ok and get exit from the window
Setting Up Using CMD:
- Open Command Prompt (Press Windows logo + R, then type cmd)
- Go to the folder where the java source file is kept
- Type SET PATH = copied path
- Type javac your_file_name.java
- Type java your_file_name and you will get your output
How to check whether java is installed on your system or not:
- Open the Command Prompt
- Type java –version press Enter
- A message similar to the following indicates that java is installed
Java version “1.4.x_xx” (or a higher version)
Java<TM> SE Runtime Environment <build ……>
Java hotspot<TM> Client VM <build ……>
- However, if you receive a message with a version lower than “1.4”, or any type of error message, or a message similar to:
Java command not found
Then you will need to install the Java Runtime Environment on your desktop.
The Java Runtime Environment can be downloaded directly from Sun Microsystems:
http://www.java.com/en/download/manual.jsp
Downloading Android studio
Image Reference: https://developer.android.com/studio
- if you downloaded a .exe file (recommended), double-click to launch it.
- If you downloaded a .zip file, unpack the ZIP, copy the android-studio folder into your Program Files folder, and then open the android-studio >bin folder and launch studio64.exe (for 64-bit machines) or studio.exe (for 32-bit machines).
- Follow the setup wizard in Android Studio and install any SDK packages that it recommends.
Understanding Android studio:
Each App Module contains the following folders: manifest, java, res.
- the User Interface:
Image reference: https://developer.android.com/studio/intro
- The toolbar lets you carry out a wide range of actions, including running your app and launching Android tools.
- The navigation bar helps you navigate through your project and open files for editing. It provides a more compact view of the structure visible in the Project window.
- The editor window is where you create and modify code. Depending on the current file type, the editor can change. For example, when viewing a layout file, the editor displays the Layout Editor.
- The tool window bar runs around the outside of the IDE window and contains the buttons that allow you to expand or collapse individual tool windows.
- The tool windows give you access to specific tasks like project management, search, version control, and more. You can expand them and collapse them.
- The status bar displays the status of your project and the IDE itself, as well as any warnings or messages.
You can get more information about the android studio and how to configure Android studio on the following link:
https://developer.android.com/studio/intro
Now as you are done with setting up your environment, you are ready to develop your own Android App.
Building your first app (“Hello World”)
Creating a New Project
- From the window of android studio click on ‘start a new android project’
- Now select an empty activity, click on next
- Give a name to your project under the ‘Name’
- Give a package name
- Select location to save your project
- Select Minimum SDK version (select 5 or above)
- Click on next and wait until your project gets synced
Android Studio provides you with some prewritten code of Hello World.
Understanding Code:
Before Running the code let’s first understand the code.
There are two files that are provided by Android Studio namely MainActivity.java and activity_main.xml.
activity_main.xml:
In this file, we define the layout or User interface of our app.
Like in the above image we have a Constraint Layout inside which we have a TextView that has a text “Hello World”.
This screen is visible whenever you run your app for the first time.
We have many User Interface components that we can add to make our layout.
You can get more information about layouts here.
MainActivity.java:
In MainActivity.java we write the functionality of your application.
In the above image, we have a package name at top of the .java file, this is the package name that you gave when you created your new project.
Then we have a MainActivity class that extends AppCompatActivity.
Inside that we have an OnCreate (an override method), this method will be invoked whenever this activity is first created, in this case when a user opens the app for the first time.
setContentView method sets the layout of the activity.
Whatever function that we want that our layout must perform like Button clicks or fetching data from the database or from the internet we implement them inside this MainActivity.java file.
Run Your App
For running your app, you can download Emulator, or You can also run on your device.
Android Studio Emulator
From the Android Studio main screen, go to Configure -> AVD Manager (Android Virtual Device Manager)
Press the “+ Create Virtual Device” button.
- Choose the type of hardware you’d like to emulate. We recommend testing against a variety of devices, but if you’re unsure where to start, the newest device in the Pixel line could be a good choice.
- Select an OS version to load on the emulator (probably one of the system images in the “Recommended” tab) and download the image.
- Change any other settings you’d like, and press “Finish” to create the virtual device. You can now run this device anytime by pressing the Play button in the AVD Manager window.
You can also run your app using your own device:
- To run your application on your mobile app:
- Open Settings
- Go to About Phone
- Click on Build number until you get a message that ‘you are a developer now’.
(Settings > About Phone > Build Number)
Before you can use the debugger and other tools, you need to enable USB debugging.
To enable USB debugging, toggle the USB debugging option in the Developer Options menu.
Now you can see Android studio you got your device name for running your application click on Run button to run your app.
Now on your device, you can see your built application.
You will get output on your Emulator or on your mobile device:
Congratulations! You just built your first Android App.
Follow me on GitHub to get more information about my next articles.
Important Links:
Download Java: https://www.java.com/en/download/
Java Tutorials: https://www.tutorialspoint.com/java/index.htm
Download Android studio: https://developer.android.com/studio
Learn more about Android Studio: https://developer.android.com/studio/intro
Official Android Developer Page: https://developer.android.com/index.html
Google Developers Codelabs provide a guided, tutorial, hands-on coding experience: https://codelabs.developers.google.com/?cat=Android
Links for Contact:
GitHub: https://github.com/8426988382
Email: Tushar Tambi
References: