An analysis of Android studio directory structure!!!

Source: Internet
Author: User

An analysis of Android studio directory structure

Turn from: 1190000002963895

At the request of your friends, write this article, let us briefly understand the location and purpose of different directories (files) in Android Studio. First look at the simplest directory structure of the next app

"= = good Complex appearance"

OK, let's see, first, put so many files into such three pieces first.
1. Compiling the system (Gradle)
2. Configuration files
3. Application Module

Gradleis a set Groovy of compiled system scripts recommended by Google (you can also use ant, of course), and the specific introduction and documentation can refer to this portal: https://developer.android.com/tools/building/ Plugin-for-gradle.html
If you learn, the project will be Android compiled at a good understanding (in short, very cool ~), its shortcomings are inefficient, and then because there is the existence of kungfu nets, so the bintray load-dependent will be relatively slow.

The words in the above figure gradle are gradle related to some documents.
The use of Android in Gradle Wrapper Gradle a layer of packaging, I guess the reason for this is because the Gradle update speed is too fast, for the sake of compatibility, just out of this set of plans. (Please correct me if you think there is a problem with this conjecture)
gradlewThe relevant documents are and Gradle Wrapper related. Let's make app a list of files other than folders.

Td>.gitignore
file (folder) name purpose
. Gradle Gra DLE compilation system, version specified by wrapper
. Idea files required by the Android Studio IDE
Buil D where the generated files are stored after compilation
gradle wrapper where the jar and configuration files are located
git ignore file
build.gradle gradle compiled related configuration file (equivalent to makefile) /td>
gradle.properties gradle Related global property settings
gradlew *n Gradle wrapper executable under IX
graldew.bat windows gradle wrapper executable
local.properties Local Property settings (key settings, Android SDK location, etc.), this file is not recommended for uploading to VCs
settings.gradle and setting related Gradle scripts

1, Gradle folder: There are two files, Gradle-wrapper.jar and gradle-wrapper.properties, they are gradle wrapper. Gradle projects will have, you can create them by command Gradle Init (provided that the Gradle is installed locally and configured in the environment variable).

2, Gradle.properties: From the name to know that it is a configuration file, yes, this can define some constants for build.gradle use, such as can configure the signature information such as KeyStore location, password, Keyalias and so on.

3, Settings.gradle: This file is used to configure multi-module, such as your project has two modules Module-a,module-b, then you need to configure in this file, the format is as follows: Include ': Module-a ', ': Module-b '.

4.gradlew and Gradlew.bat: This is the shell script under Linux and the batch file under Windows, Their role is to download the corresponding Gradle version according to the Distributionurl in the Gradle-wrapper.properties file. This ensures that the unified version of Gradle is used when building in a different environment, even if the environment is not installed Gradle, because Gradle wrapper automatically downloads the corresponding Gradle version. The use of Gradlew is identical to gradle, such as the build Gradle build command, which you can use Gradlew build. Gradlew is the abbreviation for Gradle wrapper.

1. Import the local jar package: Unlike Eclipse, Android studio imports The local jar in addition to placing the jar package in the module's Libs directory, it has to be configured in the Build.gradle of the module, configured in dependencies The following declaration is made under the node: Compile files (' Libs/xxx.jar ') if there are multiple jar files under LIBS, you can declare this:

1. Compile Filetree (dir: ' Libs ', include: [' *.jar ']) 2. Import Maven Library: Compile ' com.android.support:appcompat-v7:21.0.3 ' visible, The format is compile ' groupId:artifactId:version ' 3. Import a project:

These are some of the files that are related to external files. Let's look at the files in the more important app modules.

This is the file directory structure under the app module, describes their use

file (clip) name Use
Build The location of the compiled file (including the final generated apk is also in this area)
Libs The location of the dependent libraries ( jar and aar )
Src The directory where the source code resides
Src/main Where the main code is located (src/androidtest) is where the test code is located.
Src/main/assets Some files that are included with Android
Src/main/java Most importantly, where our Java code resides
Src/main/jnilibs The default location (. so file) where some of the JNI's dynamic libraries reside
Src/main/res Where the Android resource file is located
Src/main/androidmanifest.xml Androidmanifest don't have to introduce it ~
Build.gradle The Gradle configuration associated with this project is equivalent to the makefile of this project, and the dependencies on some projects are written here.
Proguard.pro Code Obfuscation configuration file

The above is Android Studio a simple introduction to the directory structure ~

There are questions can be directly message, I will reply as soon as possible.

Please follow me on GitHub and @Gemini

An analysis of Android studio directory structure!!!

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.