Android Studio and Android App Project Structure Part 1
Welcome to the second tutorial for Android App Development, focused on the basics of Android Studio, which is the official IDE for developing Android apps.
If you have not read my previous post I recommend that you check this post first before jumping on this one. The previous post shows how you can set-up the development environment.
Okay, so once you have installed Android Studio, fire it up and wait until it is completely loaded.
This is the screen that you see in Android Studio while running it for the first time. Click on “Start a new Android Studio project” to create a new project.
On the next screen you will be asked to enter a project name, company domain and the path where project will be saved.
Enter whatever name you want. It is just the project name and not the actual name of the app. You will be able to change the app’s name later.
This is the company domain name, and you should enter the website domain of your company. I’m using “technologyleaks.com” in domain, but you can just use your name if you don’t have any domain.
The package name of the app is also generated from domain name and application name. For example the package name for Facebook Android app is “com.facebook.katana”, in which the “com.facebook” represent their domain “facebook.com” and “katana” is the actual app name.
Another thing to note is that even though the app name of Facebook Android app is “katana” it still shows “Facebook” in your device. That is because “katana” is actually project name while the name shown in the launcher can be changed in manifest while. It’s fine if you don’t completely understand this at this time. We will get back to this detail again.
It is simply the location where Android app project will be saved on your hard drive.
Hit Next button to go to second screen.
This screen shows you some compatibility settings, where you can choose which Android Version will your app support.
Here is a table provided by Google Dashboard showing the percentage of devices running Android operating systems. The latest table can be found here.
Since this tutorial is about developing mobile apps, I have selected Phone and Tablet. I also want to support devices that running at least Android IceCreamSandwich (4.0.3) that covers 97% device at present.
Press Next again to continue.
This is where you choose the template for the first screen. We will be using these options later, for now just select the “Empty Activity”, and hit Next.
Now these are some Activity customization, including JAVA Class name, and Layout file name. Leave everything default and press Finish to end the wizard.
What is an Activity?
You can consider an Activity as a screen of app. Each screen in an Android app is called Activity, which consists of two parts; JAVA class that contains the programming logic, and the XML layout file which contains all the GUI (Graphical User Interface).
This is the final screen that you see after successfully creating a new Android app Project. It will take a while to build and index stuff for the first time, which can sometimes take up to 15 minutes, so you have to be patient.
Let me explain some important parts of the Android Studio IDE now. Look at the little numbers in the image below and then check its description accordingly.
1. The Package
It is the JAVA Package that contains the JAVA source code files. An Android app Project has some other packages too, but this is the main package that contains source code including the business logic. It is the same package name that we discussed earlier while creating new project.
You can collapse or expand the packages to see what is inside them.
2. JAVA Source code file
Now this is a JAVA file which holds our logic. When you create a new project only one class is created that is our MainActivity.
3. Code area
When you double-click an Activity (JAVA source code file) it will open up in this code are where you can edit the code. All the files are opened as tabs, just like you open tabs in browser. You can switch between them and close them when done.
4. The Run button
This is where you fire up your Project and runt it. You will be asked to choose from available device to run the app on.
5. The Debug button
It is the same as running an app, but attaches a debugger to device. The debug mode allows us to put breakpoints where the app will pause and allow us to see values of certain variables, and objects, etc. This is useful when your app is not working as it is supposed to do, you can check values and find out the cause of the problem. We will further discuss this in a separate post later.
6. Android Device Manager button
This launched Android Device Manager where you can see the list of Virtual Device that you have created, and also create a new device.
7. Android SDK Manager button
This button launched Android SDK Manager, which shows you different components of Android SDK that you have installed and the updates that are available to install.
8. Android Monitor
This tab opens up the Android monitoring tools like LogCat, and memory monitor etc. These monitors are used to find the app messages, crash information, and the memory information. We will be using these tools throughout the course.
That’s it for now. In the next post we will take a look at the code of Activity. Keep visiting TechnologyLeaks for more tutorials.