Android App Development | What’s new in Android Studio and all about App Development | First Project

Hey everyone, today we’ll learn about the basics of android development and see the interface, the menu and all new features in the latest version of Android Studio.

So if you don’t know anything about what we’re discussing here, maybe you should follow the other two previous articles here and follow all the steps mentioned in them. Here in this article, we will write the programming in java language so you should know the java language. In next article, we will write in Kotlin language.

So I assume that you know all the basics about it now and have installed Android Studio latest version. As of now, Android Studio is available in version 3.5.3 in the stable channel. So let’s see how does it look like now and all the new features launched in it.

What’s New in Android Studio?

See the image below and follow the instructions to check the new features launched in Android Studio 3.5 version.

what's new in android studio

Android Studio:

android studio top menu
Here you can see all the different menu items that we’ll see the need in future. For example, in “Run” menu we can run the application and in “Build” menu we can create the .apk file for publishing the app to the Play Store.
project navigation
This’s the project view for showing the opened files.
android studio build menu
This is the build menu where we can run our app or debug the app or select the running device (emulator or physical device).
change between Android, Project views
We can switch between Android, Project views. Click on the “Android” drop down .

Project View:

android project view

To see the actual file structure of the project including all files hidden from the Android view, select Project from the dropdown at the top of the Project window. When you select Project view, you can see a lot more files and directories. The most important of which are the following:

  • build/: Contains build outputs.
  • libs/: Contains private libraries.
  • src/: Contains all code and resource files for the module in the following subdirectories:
  • androidTest/: Contains code for instrumentation tests that run on an Android device.
  • main/: Contains the “main” sourceset files: the Android code and resources shared by all build variants (files for other build variants reside in sibling directories, such as src/debug/ for the debug build type).
  • AndroidManifest.xml: Describes the nature of the application and each of its components.
  • java/: Contains Java code sources.
  • jni/: Contains native code using the Java Native Interface (JNI).
  • gen/: Contains the Java files generated by Android Studio, such as your file and interfaces created from AIDL files.
  • res/: Contains application resources, such as drawable files, layout files, and UI string.
  • assets/: Contains file that should be compiled into an .apk file as-is. You can navigate this directory in the same way as a typical file system using URIs and read files as a stream of bytes using the AssetManager . For example, this is a good location for textures and game data.
  • test/: Contains code for local tests that run on your host JVM.
  • build.gradle: (module)This defines the module-specific build configurations.
  • build.gradle: (project)This defines your build configuration that apply to all modules. This file is integral to the project, so you should maintain them in revision control with all other source code.

Project Files:

You can see these files when you switch to Android view in the drop down. The main project file structure described below:

  • manifests: Contains the AndroidManifest.xml file.
  • java: Contains the Java source code files, separated by package names, including JUnit test code.
  • res: Contains all non-code resources, such as XML layouts, UI strings, and bitmap images, divided into corresponding sub-directories.

Create your first “Hello World” app

Follow the steps:

create new project window in android studio
  • First click on the File>>New>>New Project or, click on the “Start a new Android Studio project” on the start menu, you will see an window like shown in the above image.
  • You can select any type of activity as shown in the image above, but for now we’ll select “Add No Activity” option (select that and click on Next).
configure projects
  • Then on the next window, fill the all inputs as shown in the image:
    • Name: Your Application Name
    • Package name: Your unique app id for play store
    • Save location: Where to save all the files in your computer
    • Language: Select between two officially supported development languages (We will select Java here.)
    • Minimum API level: Your minimum supported Android version
  • Fill the everything as shown in image and click on the Finish button.
select empty activity
  • As we selected the no activity option, nothing will be there under your application package name in “java” directory. So we need to create our first activity. Follow the image above and right-click on your package name under “java” in “app” directory when you’re in the Android view.
  • And then click on New>>Activity>>Empty Activity, you will see an window like this.
create first activity
  • Then write your activity name, select the “Generate Layout File” (this option will generate the layout for our activity automatically so that we don’t have to do it manually.), then select the “Launcher Activity” option (when setting this up, when we run our app this activity will be launched in the beginning. So we need to create the launcher activity once and link others to it.).
  • Then select the language java and click on Finish button. Then wait for sometime, Android Studio will create the activity and layout files for you. Then you can see something like this:
first activity code

Congrats, you’ve created your first application, now will customize it a little bit and check how does it look like. Now click on the activity_main.xml or, open it from res>>layout>>double-click on the layout.

Then follow the below image and write everything in there:

write hello world textview
We created a normal textview for showing the text in the screen.

Let’s understand all the code below:

  • android:id For setting an unique id for the textview. This id is different for every item in here like we can have multiple textviews or buttons but with different ids. This id, we need to apply functions to the views (textview to change text or set text)
  • android:text For setting some text for the textview in the layout. We may or may not set the text in xml layout, so it’s optional and can be empty.
  • android:layout_width Here we set the width of the textview. “match_parent” is for the text to occupy the whole parent layout width. We set this to match_parent here as we only had one textview, otherwise we could have set it to wrap_content (whatever the text will be the textview width will be upto that.
  • android:layout_height Same as layout_width except it’s for height.
  • android:padding Setting some padding to the every side of the text view. For each side, we can use paddingRight or paddingLeft.
  • android:gravity It’s for the gravity of the view i.e textview here. We can use layout_gravity for parent view gravity. It is to set the textview to the center or, right like sides.

Okay, now we understood the all codes written in the xml, we will learn about java part in next article when we explore and create another application. So no let’s run our app and see how it looks like..

run the application
Click on the play button like icon in the build menu or click on the Run “app” under Run menu.

Now we are done creating the first android app project. In the coming articles we will learn other topics and explore android app development more. Until then if you have any questions, comment down below or email us directly and save this link for future android app development topics.

Leave a Reply

thirteen + nineteen =