No matter what IDE is used to develop Android, after integrating the official Android SDK and creating an Android project, the project will include a complete set of Android project files by default, and this project can be directly run on your real machine or emulator.
This article mainly analyzes the file structure of this default complete set of project projects, so that we can be proficient in targeted development when developing our own projects.
This file can be regarded as the soul architect of the entire Android project. It not only defines the functional characteristics required by your Android program when it runs, but also defines the permissions required by the Android program and the core components of the Android program.
Here is a brief introduction to one of the most important node elements we have encountered at present: <uses-sdk>.
This node defines the device compatibility issues of your application. We all know that Android devices are diverse, but different devices have Android versions, such as Android 2.2, 2.3, Android 3.0 for tablets and now. These versions have defined SDKVersion. In this node, we have to specify the minimum Android version (android:minSdkVersion) and the target Android version (android:targetSdkVersion). So it should be like:
<manifest xmlns:andro ... >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
...
</manifest>
The minimum Android version is specified as 8 and the target version is specified as 19. It should be noted that:
:targetSdkVersion should be set as high as possible. The function of this property is to be when the SDK version of the device is consistent with the specified target version, and the device does not need to turn on the compatibility function;
:minSdkVersion and this property withdraws the backward compatibility of your application. Once the SDK version of the device is lower than this number, the following error will occur:
Installing
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/"
pkg: /data/local/tmp/
Failure [INSTALL_FAILED_OLDER_SDK]
1. If targetSdkVersion is not specified explicitly, it is equivalent to minSdkVersion by default;
2. In addition, we sometimes see android:maxSdkVersion, which has the opposite effect to minSdkVersion. This property is mainly reflected in Android 1.5, 1.6, 2.0, and 2.0.1. Once these old systems have completed system updates, they will reproduce and verify and install the applications installed in the old system. Once they find that maxSdkVersion is lower than the new system after the upgrade, the new system will not install these applications.
src/
As the name suggests, the src directory stores the source code file of the application. Of course, after the program is compiled, this directory will no longer exist, otherwise the source code will be stolen, right?
res/
The res directory refers to the directory where the resource file resource is stored, which contains some subdirectories.
For example, the directory where pictures are stored is drawn-xxx. In the current default environment, there are generally 4 similar directories, which are used to store pictures of different resolutions (drawable-xhdpi/hdpi/mdpi/ldpi). In order to adapt as many models of different resolutions as possible, good applications need to make multiple sets of pictures of different resolutions and store them in these 4 directories.
There are also layout files used to store the user interface GUI (application interface) in the res directory, and these layout files are stored in the layout directory;
There is also a directory used to store the xml that defines the variable set, that is, values. This directory can define variable sets such as colors and strings.