Day 1: Introduction to android studio.
In this android development series I am revising my old concepts of android development and learning up new skills for a particular project about which you will come to know at end of this series.
So starting from Android development, android development is domain where we make android apps . We can use java or kotlin , either of them for developing native apps. Kotlin is declared as official language for android development by google yet I am learning through java because of three reasons:
- Learning Java never goes to vain.
- It hardly take 1 week to switch to kotlin from java, and almost all concepts remain the same.
- Most of old companies and big companies still have there old project in java, so it still have scope.
So starting with my day 1 :
First we already have installed android studio. So we started android studio, click on start new project if you want to start new project. We generally choose empty activity, so I choose empty activity, next, then give a name to application, I gave demo app. Give any suitable package name, com.example.myapplication or com.example.demoapp. If you are coming from java background you might have heard about package. A package is something in which your all classes reside. There’s an option to save location, you can change it as per your choice, then language , it shows 2 language java and kotlin. Choose any one you know. I am working with java. Select minimum API level. Minimum API level implies the minimum android version the app support/ or app will run. So I choosen API 21, i.e Android 5.0 version as min api level. Then click finish. The gradle building and syncing will start, which may take some time depending on specification of your system. It must me connected to internet while syncing.
So coming to left side there’s are many option for project, like android, packages, project files, project source files, project non source files, problems. I have been introduced to two files : project and Android. In Project all your project files are there, including R.java. While working on project we open and work on android option.
Coming to android, there are app folders and gradle scripts.
Gradle Scripts:
Gradle Scripts consists of 7 files, out of 7 we are interested and edit only two files . The rest last five should not be changed. So the two are app level and project level build.gradle files.
Project level gradle file :
It consists of buildscript, dependencies and all projects . I remember I make changes to this file while working on firebase project by adding dependencies and all.
App level build.gradle file:
Here in android we can set compile sdk version, build tool version, min sdk version, target sdk version (max sdk) , version code , version name. It has buildTypes and dependencies section too.
App folders:
In app level folder , there are 4 subfolders:
- Manifest
- Java
- Java (generated)
- Res
1] Manifest:
It consists of a file called AndroidManifest.xml . Manifest file is brain of app. Here’s all the functionality like theme, icon, allowBackup, activity names are present.
- Allow backup , set to true by default.
- icon : decide icon of our app. (Can be changed from mipmap folder — app/res/mipmap)
- label : label (heading) and name with icon. (Can be changed from app/res/values/strings.xml)
- theme : theme of app like color of title bar and all. (Can be changed from app/res/values/styles.xml and color can be set from color.xml )
- activity : contains all the activity class files name.
- The intent filer : It is most important part of app. It decide action to be performed when app runs. It had main and launcher . The activity class in which intent filter is there, that activity runs first when app starts.
- If you want to navigate to older activity , i.e. activity before current activity, or want to navigate to main activity directly through screen, use parentActivityName = “.Activityname” in that activity section of manifest file.
2] java
It contains 3 subfolders of which we are interested in 1st one, i.e com.example.demoapp. It contains mainactivity.java file where java code for a XML design is written. It is responsible for performing activities and making ui interactive.
3] java(generated)
It contains files after build and sync operation. Not of importance.
4] res
This is main folder which decides design or look of app. It contains subfolders like
- drawable: contain images that are used in design of app. You need to paste image in this folder for using in ui.
- layout: contain activity_main.xml i.e where you write XML code that will design your ui.
- mipmap: folder where app icon images are placed.
- values : contain 3files — colors.xml , strings.xml(contains string used in id name nd all.), styles.xml(like css file) for styling layout.
In next blog I will discuss different ui component used in XML file.