Helloworld for Android

Source: Internet
Author: User

It is very easy to create HelloWorld in Eclipse + ADT. Just follow the instructions in the next step. The focus of this article is not on how to create, but on understanding the files of the HelloWorld project. For more information, see

The HelloWorld directory structure is as follows:

Src: Stores the logic code of the application. The code here is manually written.
Gen: Stores resource Code. The Code is automatically generated.
Assets: Stores mp3 and other video resources
Bin: Generated executable binary file directory
Libs: Referenced library, which is consistent with the directory in bin/dexedLibs.
Res: Resource file. When resources are added to this directory, the records are automatically recorded by gen/R. java and automatically recorded in R. java.
AndroidManifest. xml: The total configuration items of the project, recording the global configurations used in the Application
Ic_launcher-web.png: This is to use the displayed icon for the google Play market. It requires a 512x512 High Resolution icon.
Proguard-project.txt
Project. properties

These two files are used in code obfuscation to protect Android projects. The official documentation is:Http://developer.android.com/tools/help/proguard.html

Let's take a look at it one by one:
Src
The folder that stores user code. There is at least one Activity in it. The concept of Activity is the interface, which is equivalent to Windows Form in C.

We can see that at least one onCreate function is called during the rendering interface. Here we use R. layout. activity_main for rendering. This corresponds

The resource descriptor is followed by the activity_main equal sign.

Here, let's take a look at the R class.

Gen/R. java

Each class in R corresponds to a resource in res,

For example, layout corresponds to res/layout.

Drawable corresponds to res/drawable-XXdpi

Therefore, the preceding R. layout. activity_main corresponds to res/layout/activity_main.xml. In this way, the interface and logic are separated, which is a typical concept of mvc pattern layering.

Gen/BuildConfig. java

There is a global DEBUG switch in it. You can use this switch for logging and debugging operations.

But how can I modify this? Files under gen should not be manually modified, For details refer to: http://drovik.com/html/5701262218.html

Bin

This directory is the directory for generating files. As you can see, it generates a copy of the apk package and AndroidMainifest. xml in the folder.

Bin/class. dex


The java bytecode file generated after java compilation is equivalent to the java. class file. However, because the dalvik Virtual Machine Used by Android is incompatible with the standard Java virtual machine, dex and class are different.

Some tools on the network can decompile Android code through dex. Like this: http://code.google.com/p/android-apkdb/

Bin/HelloWorld.apk

This is the application package file ). An apk file contains compiled code files (. dex files), file resources (res), assets, certificates (certificates), and list files (manifest files ). APK is based on the zip file format.

Bin/resources. ap _

This is a collection of all resource files, actually in zip format. We can modify the suffix, decompress it, and we can see that the structure is mainfest, res, etc.

Bin/dexedLibs

Corresponding to the jar package referenced in libs

Res

This directory is all resource files.

Res/drawable-Xdpi:Resources with different resolutions are stored here.

Res/layout:Store Layout resources. The onCreate method in src loads the activity_main resource.

Res/menu:Menu of the mobile phone

Res/values:Used to store some variables and parameters.

Res/values-XX:Different parameter settings are available for different devices or android versions.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.