Studio, it is a cool interface, which helps us in creating, developing, building, running, publishing our android application. The first key point to remember is that, an android app in your phone is nothing but just an .apk file that is installed and running. So the android project we create will have .apk as final deliverable.
An android project can have more than one .apk deliverables, which support different versions of android and different devices across the globe.
Our aim is to develop an app which displays “Hello Android” text on the screen. Creating project is like creating a new file in your word application but the devil is in details. Knowing about what all project creation takes and doing it in right way will make you stand as an expert in Android.
Before jumping into creating apps, prototyping and UX designing is very important for creating successful app. It makes your end product defined and structured.
Creating a new project involves Configuration, Selecting form factors, Adding and Customizing activity, Building project. Click on “Create New Project” to create new android project. Create New Project window will be opened as shown below:
Following are mandatory inputs to be provided:
Name of the project you are creating
|Company domain||Name of your company domain (ex: esprinkle.com)|
|Package name||Name of the package held by your project. It is generally the combination of Company domain + Application name|
|Project location||Location on your drive to store the created project files|
As you can see my application name is “TastingAndroid” and company domain is “esprinkle”. Package name is auto populated by combing both which is “esprinkle.tastingandroid”. Package name plays a vital role in making your app visible in the search results of Google Play Store. When you search in Play store with “TastingAndroid” as the search term, there can be many applications with the same name. Here, the company domain, which is part of package name makes the difference from other similar apps. Our app can be listed first.
Play store search by querying package names of applications. Hence choosing the unique package name while creating an application is very important.
Select Form Factors
It is our choice to choose on which devices our app should run on. In is evolving world of technology, there are many forms factors that we interact with. A form factor in this context is nothing but which enables me to access android operating system. As we see smartphones, tablets, smart watches, smart TVs, smart cars, Google glass, etc., which are enabled to run android operating system are the different form factors available for us to run our android app.
Going forward we need to be clear with little terminology:
API (Application programming interface)
|An interface that allows programs to interact with each other|
SDK (Software development kit)
|Set of tools that allows the creation of applications for certain development platform|
API is like the building blocks of some puzzling game that a child plays with to join blocks in different shapes and build something they can think of.
SDK, on the other hand, is a proper workshop where all of the development tools are available, rather than pre-shaped building blocks. In a workshop you have the actual tools and you are not limited to blocks, and can therefore make your own blocks, or can create something without any blocks to begin with.
Coding without an SDK or API is like making everything from scratch without a workshop – you have to even make your own tools
Above window prompts for selecting form factors and their API levels. Every form factor has several API levels and a SDK. Initially we shall proceed with development for ‘Phone and Tablet’ form factor. There are some millions of phones and tablets out there on which your app can run. Every phone/ tablet will have its respective API level.
Hence selecting the proper and appropriate API level will make you app run on those many devices that has the selected API level and above it. ‘Help me choose’ link will show the respective features which each API level supports.
As API level increases the number of features supported by devices increase. Hence developing for lower API levels will make you app run on more devices.
Above window shows the cumulative distribution of API levels across the globe and features supported by the selected API level.
We can interact with a website using its webpage. A website contain webpages and an app contain screens. Each screen is referred as an ‘Activity’. Hence the number of screens you see inside an app is nothing but those many number of activities. Again here as we know, a website’s has a front end to interact with users and a backend to interact with the database. Coming to our app, when we refer an ‘Activity’ is has 2 files.
|A XML layout file to design our front end|
|A JAVA class file to code for the interactions we make with the front end controls|
These two files are together are referred as activity. So as you can observe in many applications there are many forms of screens which are in common like displaying map, showing full screen, login screen, navigation drawer screen, setting screen. These screens are displayed here to select along with the blank activity.
Listed screen types will have the default implementation and code for the same which help in understanding the structure of the same.
Select blank activity and click ‘Next’ to customize the blank activity.
Every activity will have three things to be mentioned and mandatory.
Name of the JAVA class file
Name of the XML layout file
|Title of the activity which will be displayed on the screen title bar|
As in a webpage, HTML code will help in showing up the controls. Here in android layout file, XML code will help in showing up the controls on the activity. Front end in android is coded using XML. Each XML file is connected to JAVA class and together they form a screen/ activity.
Menu resource file is not mandatory. It will contain the menu items to be displayed on the title bar. This file is created with the activity to assist with menu options. Click on ‘Finish’ to create the project.
On click of ‘Finish’, the actual project creation is started by Gradle. Gradle is the build system which comes with android studio which help us in building, testing, running and packaging the apps. Here Gradle will be creating the android project with the mentioned configurations. Gradle is an advanced build toolkit that manages dependencies and allows us to define custom build logic.
After Gradle finishes creating our android project, here is the complete android studio window of the new project.
Gradle creates the first version of .apk file and places in ‘app’ folder of the project when it creates project for the first time.
Download this tutorial
343 total views, 1 views today