Exploring Android Studio as a beginner
Hey folks! In this article, we will explore android studio, in the last article we have learned how to create new project in android studio.
After building your project, following screen will appear in Android studio
Note: Please note that, in this article, we will be using Kotlin language to learn and build android applications.
In this article, to explore android studio, our main focus will be on app folder and gradle scripts, which are on left of your android studio.
Check on the top, there is manifests folder, it has AndroidManifest.xml file
AndroidManifest.xml:
- This file describes essential information about our app to Operating System and Google Play.
- Manifest file is required to declare the app’s package name
- It is required to declare the component of the app like:
- activity
- services
- receiver
- provider
This is the file where we have to add all uses-permission that we are using in our app. For example, if we want to read the external storage of use, then we have to add the following line in our AndroidManifests.xml file.
This is the file where we have to add all uses-permission that we are using in our app.
If we want to access other things, we have to follow the same process.
- We can change the launcher icon of our app from this file.
- In this file we declare what types of Hardware or Software feature our app requires. For example, if our app requires Bluetooth and without it, our app will not work, then we can declare this in the below way:
We can define the intent-filter in this file.
App activities, services, and broadcast receivers are activated by intents.
For example, we can change what activity will open when our app will open means we can change the launcher activity.
Java Folder
In this folder, we will write the code for our apps like what will happen when we click on the button and all.
For example, in the above image, we have the file MainActivity. This file will handle the functionality of the MainActivity Screen.
res folder:
This folder is used to store the value of resources that we are using in our project like colors, strings, layout, styles and drawable.
- drawable: This folder contains the different types of images used for the development of the application. It also contains the XML drawable which are used to describe shapes (color, border, gradient), state, transitions and more.
- layout: It contains the XML code of all layouts of our project.
- mipmap: It contains our app/launcher icons (which are shown on the home screen). >It’s best practice to place our app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density.
- values: This folder contains the value of color, strings and style.
- colors.xml: The colors.xml is an XML file that is used to store the colors for the resources. We can use these colors throughout our app.
- strings.xml: It is used to define the strings in one file so that it is easy to use same string in different positions in the android project
- themes.xml: In this file all the themes of android project are defined white/dark.
Gradle Script
build.gradle(Project:applicationName) This file is in the root folder of the project and its configuration settings apply to every module in the project. A module is an isolated piece of the bigger project. In a multi-module project, these modules have their jobs but work together to form the whole project. Most Android projects only have one module, the app module.
build.gradle(Module:applicationName.app): The file here is in the app folder. Its build settings apply only to the app module. If there were another module, then that module would have its build.gradle file, too.
In this file we can define:
- applicationId: This is the package name of our app
- minSdkVersion: It specifies the minimum API Level on which the application is able to run.
- targetSdkVersion: It specifies the API Level on which the application is designed to run
- versionCode: It’s a positive integer that’s used for comparison with other version codes. It’s not shown to the user, it’s just for record-keeping in a way.
- versionName: This is the version string seen by the user. It isn’t used for internal comparisons or anything, it’s just for users to see.
- dependencies: Dependencies refer to the things that supports in building your project, such as required JAR file from other projects and external JARs like JDBC JAR or Eh-cache JAR in the class path.
Also, check for bottom bar of android studio, you’ll see following options there
Version Control: If git is enabled in your project then you’ll see git branches tree and commit history there.
TODO: It’s like a reminder of your tasks in the working project
Problems: It’s very helpful when writing a code as well as testing your code, android studio has very well defined description of errors which you can copy from there and search for online references.
Terminal: It’s a general terminal to execute your handy commands
Logcat: It is a command-line tool that dumps a log of system messages, including stack traces when the emulator/device throws an error and messages that you have written from your app with the Log class.
Profiler: The Android Profiler tools provide real-time data to help you to understand how your app uses CPU, memory, network, and battery resources.
Layout Inspector: The Layout Inspector in Android Studio allows you to compare your app layout with design mockups, display a magnified or 3D view of your app, and examine details of its layout at runtime. This is especially useful when your layout is built at runtime rather than entirely in XML and the layout is behaving unexpectedly.
Thanks for reading this article till the end hope you liked it, save for later! See you all in next article.. Happy Coding!!😄