In this tutorial, I will show you how to setup your system to start developing your first Hello World using the Android Studio.
Android is based on a modified version of the Linux kernel, and includes following versions till date as shown in the figure below. Please read it from top to bottom. Android 5.0 Lollipop is the latest version of Android currently launched with Android studio 1.0.
You can also run android versions with Eclipse environment, but using Android studio is best practice developers do nowadays.
Let’s have a look at the Android features before setting up the things for Android studio…
In this tutorial. we will see the steps to setup Android, Prerequisites to start and will come to know how to make your hello world application in android studio.
Android Studio is an integrated development environment (IDE) for the Android platform. It was announced on May 16, 2013 at the Google I/O conference.
The Android Studio is freely available under the Apache License 2.0 and it was in early access preview stage starting from version 0.1 in May 2013. The first stable build was released in December 2014, starting from version 1.0.
With the release of Android Studio, you have access to a whole new set of features to enable your development workflow. Some of the key features of Android Studio are listed below…
Android, and several popular frameworks for it, make all of these features really simple to implement. That is the reason you should start learning it straight from here today itself if you find this worthy.
Have you ever thought what is Android’s development cycle and how does it works? Let me point out the whole cycle briefly for you:
At the end of this tutorial you will be able to do below things:
If you want to start writing code right away and figure out the various Android features as quickly as possible you are not behaving any wrong. Android is actually interesting enough to start immediately. One of the most important parts of getting started with a new platform is setting up the environment which supports that platform.
For beginners, it’s very important to follow each step and understand how to setup things to getting started with android development. Even if you follow everything correctly, you may have some issue, depending on your system configuration or product versions. Sometimes even professionals will get some trouble with the new Android Studio if will not follow the steps properly.
The first step towards installing android is to check if you have the Java Development Kit (JDK) installed. You might already, even if you don’t know for sure. If you don’t have the JDK installed, you should download the JDK from Oracle.
When ready, move on to the Android Studio page and click the button to download the correct version for your Operating System.
Google is constantly updating this page, so the version you see may be newer than the screenshot above. Once you have clicked the button you’ll be asked to agree to the Terms and Conditions:
Read these carefully, accept the Terms and Conditions and click the “Download Android Studio”. Your download will start. It may take a few minutes or more according to your download speed but once finished you can install Android Studio similar to any other program.
Once you downloaded and installed Studio, Launch it and you will see below screen.
Once Android Studio has finished loading, you’ll be see the Setup Wizard when the first time Studio loads.
Click next and follow the instructions to setup the studio. After a few minutes you will have everything you need to begin building Android Apps and you will see the welcome screen as below.
Every version of Android has its own particular SDK you can use to build applications that can run on. As a component of the Setup Wizard you will have the most recent SDK accessible to you; then again its helpful to know how to introduce extra SDK’s whether you have to work with more popular devices that don’t run the most recent version of Android.
SDK’s permit you to make AVD’s (Android Virtual Devices) to test your Apps on, customized to your individual setup. Need to see how your Android App looks on a TV estimated screen? In the event that you have a screen enormous enough you can discover all the more on AVD’s later. You can get it from the Android Studio welcome screen, click Configure.
The menu will slide crosswise over and present another menu with different alternatives. You can choose to decide what you want for example start SDK Manager. Here you can download a particular version of Android to create or test your application on. It also contains other valuable things, for example, API documentation, code samples and even software kits that communicate with Android, for example, Android Wear and Google Glass.
For now let’s focus on downloading a version of the Android SDK. Click the SDK Manager option, a new window will present itself to you with checkboxes, folders and statuses across the page.
Click the tick box next to the folder icon for Android 5.0.1 or whichever you want to install/update, this will select everything within that directory for download. You can use SDK Manager anytime to delete anything you don’t use. Your SDK Manager window should look something like the picture shown above.
Click “Install packages” on the bottom right of the SDK Manager. A new window will appear with a drop down list of the packages you wish to install, simply click the root of the drop down list and then click the Accept License radio button in the bottom right.
You may need to do this for multiple licenses depending on what packages you download.
Finally, click the install button at the very bottom right of the window to start download.
The window will disappear and the SDK Manager will begin to download and install your selected items. Once the SDK Manager has finished downloading and installing your items you can move onto creating your first Android App!
Once you have finished with installing and setting up things to begin with Android Studio let’s make your first project. Usually first programs are called “Hello World.” J By the end of this section, you’ll be able to load your helloworld app onto a device.
Android Studio has a nice little step-by-step tool to help you make your project. Click Start a new Android Studio Project from the Welcome to Android Studio screen:
You will get the project creation screen here as below:
Enter MyFirstApplication name as shown above. Enter Company Domain field. By default studio will put example.com here. The Package Name is used to uniquely identify your app , by putting this you will ensure that any work an Android device does on behalf of your app always knows its source and can’t get confused between any other apps. You can set the Project location to any location on your system.
Click Next to proceed further on project setup.
The following screen is the place you choose devices and OS to target. Here we simply need an App that will run on an Android Phone. This choice is chosen as the default. The Minimum SDK drop down menu sets the lowest version of Android expected to run your application. For your first application, you’ll use the default – API 21, which is Android 5.0 (Lollipop). Each application will have different necessities and you may need to pick something else, depending upon the circumstances.
If you truly need to know more about what Minimum SDK version is best for your App then Android Studio can help you here as well. As you change the minimum SDK from dropdown list it will show the percentage coverage of that version in the market currently. Click the highlighted “Help me” link below the drop down list to see a window as shown below.
This window represents the percentage of devices supporting that particular version of Android. As we go down on the bar, the version of Android increases and you will be able to get more features to develop for your android App. But make sure to check the amount of devices that can support the version you selected. As you increase the version to higher the number of supported devices becomes lower.
Picking what Minimum SDK your App will require is actually a difficult task. It will affect what features you have available to you in your project along with the number of Android users that can run your App.
Check out the Android Dashboards, which are updated every few days to get more details on android version and supported devices.
That was enough on SDK version. Let’s go back to our discussion on new project window, click Next in the bottom right to pick more options for your project.
This screen lets you choose a default Activity for your app. An activity can take up the entire screen or it could be a simple pop-up. Available activities on this template range from a blank activity with an Action Bar right up to an Activity with aMapView embedded. Select the “Blank Activity” option and click Next.
On Next screen you will have to enter some details of your main activity which will be the starting point for you application when it will be launched.
Activity Name: This is the name of your activity to refer to in code. Once the project setup is complete Studio will create a .java class and use the content of this textfield to give the class a name. By default Android will fill MainActivity in this field.
Layout Name: As I have mentioned earlier, the layout of everything android will show to the user is defined in a special sort of Android XML. Enter the name of your xml you will be referring in your code here. “activity_main.xml” is the default value of this field.
Clicking on Finish will allow the Studio to do its behind-the-scenes operations and create your project. As it shoots out some descriptions of what it’s doing from time to time, you may notice something like the following:
You will see your project name, with some loading/building screen. The benefit of having a modern IDE like Android Studio is that it handles a lot for you. As a beginner it’s good to know, in general, what it’s doing for you.
Gradle is a new build tool that is easy to use, but it also contains a lot of advanced options if you investigate it further. It takes your Java code and XML layouts, and then uses the latest Android build tools to create the app package file, known as an APK file.
After few minutes, studio will finish building your project. Although at this stage it won’t have any code but it has few default setup which allows you to run your app on emulator or device right away. Once the gradle build will be done you will see a screen like below:
On the left you have your project folder structure, in the middle you have preview of your layout on device and finally on the right you have your layout hierarchy as well as attributes if you have a part of your layout hierarchy selected.
Before start any programming for your first app, let’s see how you will get it running. So now is time to say “Hello world!”
Until now you have installed the Android studio and created your first Project using the studio wizard. Now we will see how to run your project on device if you have android device available or you can run it on an emulator as well.
Android Studio has the ability to set up a software-based Android device on your computer and run apps on it, browse websites, debug and everything you would test on a real device known as the Android Emulator.
You can set up multiple emulators and set the screen size and platform version for each one to whatever you like. If you ran the setup wizard earlier using the standard installation then you will probably have an emulator setup already.
To set up an emulator Click AVD Manager button in the toolbar that has an android popping its head up next to a device with a purple display. Android Studio has already created an AVD to use. You’ll see a few details about it, like what type of emulator it is, what API it is using and what CPU instruction set it uses. Click on Create Virtual device button and follow the instructions to create AVD of your choice and requirement.
If you see the name of emulator in the list it means that you have successfully created the AVD and you are ready to run your app on emulator.
Now close the AVD Manager and run your app by clicking the play like button on toolbar. This will pop a new window asking to choose the device you wish to test your app on.
As we don’t have any device running currently so we need to launch emulator by selecting an AVD from dropdown list. On clicking OK emulator will get launched on some time. This may take few minutes to load emulator setup for you.
And now you will see the screen below as the output of your application.
Congratulations!!!! So finally you have built a Hello world and said Hello to all your friends from android studio window. 😉
As you can see we didn’t write any code in our .java or .xml file yet. This is android’s very basic and simple template for beginners.
To proceed we will make some changes to this basic hello world app to start making changes and adding cool features. We will now change the “Hello World” text with some other text.
Navigate to res/values/strings.xml and double-click the file. When you open the file, you’ll see three string resources in XML. These resources are accessed in different places, but it is very convenient to have all of the text used in your App in one file. Change the hello_world string. That string is the one that the app displays on the screen.
<string name="hello_world">This is my first android studio application!</string>
So remember: When you launch the App, you’re essentially doing the same thing as sending a launch Intent to the manifest. As the boss, the manifest takes a look at the Intent and decides it has the perfect fit for the job: MyActivity. The Java does the heavy lifting of opening the screen, but for what to display it goes and asks the artist, eventually leading to strings.xml.
So now You’ve entered the world of Android. You’ve set up your development environment (no easy task!), created your first app, run it on an Emulator or device, and changed the App so that it specifically addresses you. Good job. Feeling awesome!!!!!!!!!
To do this it’s necessary to get a working knowledge of what’s going on behind the scenes.
Android projects has a structure which has been followed by every project.
Java code is responsible to get the things done. All the code is placed in src/main/java directory under main project folder. It is actually a good practice to learn more and more Java as you explore Android development.
Every job needs a style. Your App is not worth unless it has great icons and images, well-designed layouts, copy text, and maybe even some smooth animations. The app/res folder contains:
This XML file includes all the information to pass on to your system about the app’s hardware and software requirements and contains your app’s name, icon, and version.
Every job in Android is going to take the form of Intent. This will allows android app to talk to each other. So, it allows you to send and receive what are essentially requests for jobs to be done.
This is the introduction to Android Studio that will help you to start working with Android Studio. There are lots of features to explore in android studio. Go Ahead and grab them all for your development. Hope this tutorial help you to start with the studio.
At the end I just wanted to explain why Android studio is better than eclipse. Android Studio will generally offer a better experience for Android developers than the traditional Eclipse development. The ADT plugin for Eclipse is no longer in active development. If you’re currently using it, you should migrate to Android Studio as soon as possible.
Google’s Android Studio is a development tool for Android based on the IntelliJ IDEA platform, which was rooled out in mid-2013 almost a year later. Eclipse, on the other hand, is the grand daddy of IDEs; although it doesn’t offer native Android support, it does have some nice tools to help you build Android applications—one such tool is the Google Plugin for Eclipse, made by Google.
Compared to Eclipse, Android Studio will offer developers a Gradle build environment and an improved user interface designer, as well as a better memory monitor and improved string translation editor. Some most appreciated features of android studio are listed below:
If you’re already using Eclipse, try out Android Studio and, if you like it, decide how easily you can switch over to it. You can accomplish the same things with either tool—it’s more a question of ease-of-use.
The Top Web Development Frameworks in 2018
5 emerging programming languages with a bright future
13 programming languages defining the future of coding
The Top 10 Programming Languages To Learn In 2018
The Languages and Frameworks You Should Learn in 2017
11 web design tools you can’t live without
The Best Python Frameworks for Web Development
50 Useful and Reasonably Popular Linux Applications