Introducing Android
Hello android
Next, I will briefly introduce the android project structure in the first two articles.
An android project includes Java source files, resource file slices, XML-based layout files, and third-party jar packages. These files will eventually be compiled into a. APK file, that is, the android application.ProgramThe executable file Android package file and the. APK file can be installed on a simulated device or a real machine.
Let's take a look at the structure of the helloandroid project we created in the previous article:
You can see that android projects mainly include:
Src/: stores Java source files
GEN/: stores the Java source files generated by the android compilation tool. These files cannot be modified manually. For example, R. Java defines some constants, which are indexes of resource files, so that we can easily reference these resource files.
Assets/: Save some static files and pack them into a. APK file.
Res/: store resource files
Res/drawable: stores images such as PNG and JPEG.
Res/drawable-ldpi/my_icon.png // store low-resolution images
Res/drawable-mdpi/my_icon.png // store images of Medium Resolution
Res/drawable-hdpi/my_icon.png // store high-resolution images
Res/layout: stores XML-based layout files.
Res/menu: stores XML-based menu files.
Res/values: stores resource files such as strings, such as files in multiple languages.
Bin/: stores compiled files.
Bin/Yourpackagename/Classes/: stores the. Class file compiled by Java.
Bin/classes. DEX: the class file is convertedDalvikThe Dex file optimized by the virtual machine is mentioned in Introducing Android.
Bin/resources. AP _: the compressed resource file is similar to a zip file.
Bin/Yourapp. APK: the executable file of the android application. In fact, it is also a compressed file, including. Dex files and various resource files.
androidmanifest. XML is a component list of the current application. It lists various activities, services, and permissions contained in the application. Let's take a look at androidmanifest in the helloandroid project. XML file:
<? XML version = "1.0" encoding = "UTF-8"?> <Manifest xmlns: Android = "http://schemas.android.com/apk/res/android" package = "com. benjamin. helloandroid "Android: versioncode =" 1 "Android: versionname =" 1.0 "> <application Android: icon =" @ drawable/icon "Android: label = "@ string/app_name"> <activity Android: Name = ". helloandroid "Android: Label =" @ string/app_name "> <intent-filter> <action Android: Name =" android. intent. action. main "/> <category Android: Name =" android. intent. category. launcher "/> </intent-filter> </activity> </Application> </manifest>
You can see the definition of the root element manifest. First, the namespace is declared and the package name is specified. Android: versioncode is the version number of the android application. It is an integer and will be compared to determine whether to update the application. Android: versionname is a version code you define for your application. It does not have to be a number, such as "Tiger 2000" or "system x. If your application is to be published in the Android Market, you must specify Android: versioncode and Android: versionname.
Android: icon indicates the icon displayed by your application. "@ drawable/icon" indicates reading the icon image under Res/drawable. Android: label indicates the name of the application, "@ string/app_name" indicates reading Res/values/strings. the value of app_name in XML. The Android: Name and Android: Label attributes of the activity indicate the class name and display name of the activity respectively. Intent-filter indicates the conditions under which the activity will be displayed.
Androidmanifest. xml also contains many elements. For more details, see the official documentation.