[JAVA] [Android Studio] [For beginners] Let's roughly explain the screen and directories

Introduction

Hello. My name is Iwachi. This time, I would like to briefly introduce Android Studio, which I am studying in various ways, so I will post it. It is for beginners. Those who have actually touched it may not be helpful at all.

Main target group

・ For beginners in programming

・ People who have never used Android Studio

・ People who have never touched the development of smartphone apps

Background to the posting

I first came into contact with Android Studio around last summer, but I'm currently in the 4th year of the Faculty of Information Systems, and I've been doing programming to some extent since the 1st year of university. Even though it was last summer, I've been busy with school assignments since then, and the next time I touched it was June of this year, so I actually touched it for about three months. www

Even though I was programming to some extent, I often stumbled in various ways when developing smartphone apps. Especially the layout and various things to consider. Therefore, even on the first Android Studio screen, it took a long time at first because I didn't know where and how to play with it.

From now on, for those who are familiar with Android Studio, I will introduce what part to use on the development screen, etc., and I have posted it with the intention of lowering the first hurdle of Android Studio for beginners.

Main contents

I will mainly introduce the parts that are used especially using the screen of Android Studio. I will introduce the parts that you will almost certainly use when developing normally, such as the structure of the directory and the meaning of the various files that are placed. Please note that the contents may be thin because it is broad and rough.

About the first full screen

First of all, start Android Studio, open a new project, and the screen immediately after that will look like this.

fullsizeoutput_255.jpeg

On this screen, I think that you will mainly play with the part surrounded by the red frame. I will explain in order. The numbers are as follows.

① Directory
② Debug view
③ Execute and build

① Directory

It's a directory that is always available on other development platforms. The point is the contents of the directory. Folders are also created automatically when creating a project, but there are various files to use. fullsizeoutput_256.jpeg I will explain each from the top.

manifest folder

1.) AndroidManifest.xml This file is an image of "a file that describes the original settings of this app". For example, if the app you are creating connects to the internet, you need to declare that you will connect to the internet with this file. I think it's a file that you will definitely mess with as you develop.

Java folder

1.) MainActicity This is a file that modifies the internal processing part of the smartphone. MainActivity.java for Java, MainActivity.kt for Kotlin. It's a programming file.

2.) ExampleInstrumentedTest I'm developing this, and I haven't used it at all, so I don't know, but it's probably a test file. If you are a beginner, you don't have to worry about it.

3.)ExmapleUnitTest This is also a test file as in 2.). If you are a beginner, you don't have to worry about it.

ganerated Java folder

I haven't opened the folder in the image, but I don't usually play with it, so I don't think it's okay to worry about it. After checking, it seems that the precompiled file from the source file is stored at build time. It seems that everything is automatically generated.

res folder

The res folder mainly stores xml files and image files. As with MainActivity, this folder will be tampered with in various ways, so it is better to remember the meaning of each folder. There are various folders, so I will explain them in order.

1.) drawable folder This folder is a folder that mainly stores layouts for image files and items such as View, TextField, and Button. The auto-generated already has ic_launcher_background and foreground, which is the layout for the app logo. It seems that you can edit the shape of the logo etc. at API level (Android terminal version) 26. It is an xml file for that.

2.) layout folder This is a folder to store layout files for android screens. The file of the first screen when the application is executed and the file of the transition destination screen when the screen transitions when the button is pressed are placed. All display files are basically present in this fielder. One file is automatically generated when the project is created.

3.) mipmap folder This is where the image file of the app logo is stored. Since logo changes and edits are set separately and automatically generated here, I don't think there is much to mess with the folder directly.

4.) values folder This is a folder to store text and color codes. For example, if you use a lot of black in the layout, you will write the color code of "# 000000" in various views. In that case, you can set the color.xml in this folder to replace "# 000000" with "ColorBlack" etc. Similarly, long text sentences and frequently used text sentences can be replaced in string.xml. By using these, you can manage the color data and text used in this project in an easy-to-understand manner, so you can work faster and share it within the team.

You can change the display of the folder of this project. Earlier, it was a drawable folder that stores image files, but in reality drawable is divided into folders, and you may not be able to get images unless you store it in an appropriate location. What you are seeing now is the omitted folder. スクリーンショット 2019-08-05 15.42.05.png Click on the location labeled Android above to see the bar. Select Project for this. スクリーンショット 2019-08-05 15.44.23.png If you change to Project and check the folders, you will find that there are two folders, drawable and drawable-v24. drawable-v24 seems to be a folder that stores image resources that can be used at API level (Android device version) of 24 or higher. Normally, you should store the images in drawable. When I copied and pasted the image to drawable on the display of Android which is not Project, there was a time when the image was not acquired because it was stored in drawable-v24, and I remember being quite addicted to it. When you copy the image, you should make sure that it is stored in drawable instead of drawable-v24.

In addition, mipmap is also divided into various types, but it seems that this is a folder for storing the application logo by dividing it into multiple pixels of different sizes. More details can be found in Resources.

② Debug view

This is the place to display run-time error statements and build-time errors. Logcat on the left side will throw an error statement when an error occurs or the application is forcibly terminated, so I think that it is often used. スクリーンショット 2019-08-05 15.15.18.png Click Logcat and the status will be described below. I think that there is a menu bar in the center of the attached image, but you can narrow down the genre of the state described in Logcat with this menu bar. For example, if you click Error, Logcat will only display the error statement. I use Log to display it in Logcat to check the storage of variables. There are not so many error statements compared to other types, so you can set the type to Error in Log.e () and narrow down to Error in Logcat at runtime to make it easier to find.

③ Execute, build

This is used when running or building. Click the green run button and select the device you want to run, and the app will be installed and run on the device screen. There is nothing special about it.

in conclusion

I have briefly introduced Android Studio, especially the directory structure as a whole. For those who are new to Android Studio, I hope that the structure of the directory will alleviate the "What's wrong ??" I've introduced the whole thing really roughly, but for more information about each segment such as drawable and mipmap, please see it on various other sites.

References

In creating this article, I studied in the following documents.

Hello World on Android (Part 2): Sesame A http://gomafuace.seesaa.net/article/300337739.html

Adaptive Icon | Android Developers https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive?hl=ja

drawable-v24: With gratitude and complaints. https://nis.at.webry.info/201712/article_1.html

About Android mipmap and drawable --Qiita https://qiita.com/gamako/items/c6b8aa43660ff6e76c14

[Andorid] It seems that the app icon should be put in the resource directory called "mipmap-" --Qiita https://qiita.com/operandoOS/items/53b0f2074a806aacd290

Recommended Posts

[Android Studio] [For beginners] Let's roughly explain the screen and directories
Android Studio development for the first time (for beginners)
Android application: Let's explain the mechanism of screen transition with simple code
Impressions and doubts about using java for the first time in Android Studio
[For beginners] DI ~ The basics of DI and DI in Spring ~
[Android] Change the app name and app icon for each Flavor
I will explain the nesting of for statements that kill beginners
[Android Studio] Set an arbitrary image for the application background [Java]
[Eclipse / github] Let's share the project created with eclipse on github For beginners
[Android] Dynamically set the height of ListView with copy (for beginners)
Introduction to Android App Development 1 Installing JDK and Android Studio for mac
Android Studio shows only one method for button onClick and Java throws an exception and ruins the app
[Android] Cause and remedy for TransactionTooLargeException
Java for beginners, expressions and operators 1
Links for creating Android apps (for beginners)
Java for beginners, expressions and operators 2
[Folio LSP] Roughly Docker (for beginners)
Classes and instances Java for beginners
[Rails] Articles for beginners to organize and understand the flow of form_with