詳細內容請參看 http://www.jetbrains.com/idea/webhelp/facet.html
以及 http://www.jetbrains.com/idea/webhelp/android-facet-page.html
那里有android studio的詳細使用說明。
A module is a discrete unit of functionality which you can compile, run, test and debug independently.
Modules contain everything that is required for their specific tasks: source code, build scripts, unit tests, deployment descriptors, and documentation. However, modules exist and are functional only in the context of a project.
Configuration information for a module is stored in a .iml module file. By default, such a file is located in the module's content root folder.
Development teams, normally, share the .iml module files through version control.
Facets represent various frameworks, technologies and languages used in a module. They let IntelliJ IDEA know how to treat the module contents and thus ensure conformity with the corresponding frameworks and technologies.
Using facets enables you to download and configure the necessary framework components, have various descriptors generated automatically and stored in proper locations, and so on.
Most facets may be added to a module irrespective of whether other facets exist.
There are also facets that extend other facets. Such facets are possible only if a module has their parent facet. For more information, seeAvailable Facets and Their Dependencies.
Library module | Select this check box to enable using the module as library project![]() |
在用android studio時,每個module都要正確第設置上面2方面的內容才能正確運行,不然系統不認為你是android程序,或是運行報錯。module比較好理解,facet是什么呢?簡單理解,facet有點想xcode中的target,就是對module資源的利用配置。在一個module中是允許多個facet存在的,每個facet會對module的資源進行不同的應用,比如以下代碼是一個android studio 創建的一個module的配置文件:
<?xml version="1.0" encoding="UTF-8"?> <module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="MyApplication" external.system.module.version="unspecified" type="JAVA_MODULE" version="4"> <component name="FacetManager"> <facet type="android-gradle" name="Android-Gradle"> <configuration> <option name="GRADLE_PROJECT_PATH" value=":app" /> </configuration> </facet> <facet type="android" name="Android"> <configuration> <option name="SELECTED_BUILD_VARIANT" value="debug" /> <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" /> <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" /> <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" /> <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" /> <option name="ALLOW_USER_CONFIGURATION" value="false" /> <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" /> <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" /> <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" /> <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" /> </configuration> </facet> </component> <component name="NewModuleRootManager" inherit-compiler-output="false"> <output url="file://$MODULE_DIR$/build/classes/debug" /> <exclude-output /> <content url="file://$MODULE_DIR$"> <sourceFolder url="file://$MODULE_DIR$/build/source/r/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/source/aidl/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/source/rs/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/res/rs/debug" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/source/r/test/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/source/aidl/test/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/test/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/source/rs/test/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/res/rs/test/debug" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> <excludeFolder url="file://$MODULE_DIR$/build/apk" /> <excludeFolder url="file://$MODULE_DIR$/build/assets" /> <excludeFolder url="file://$MODULE_DIR$/build/bundles" /> <excludeFolder url="file://$MODULE_DIR$/build/classes" /> <excludeFolder url="file://$MODULE_DIR$/build/dependency-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/libs" /> <excludeFolder url="file://$MODULE_DIR$/build/manifests" /> <excludeFolder url="file://$MODULE_DIR$/build/res" /> <excludeFolder url="file://$MODULE_DIR$/build/symbols" /> <excludeFolder url="file://$MODULE_DIR$/build/tmp" /> </content> <orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="library" exported="" name="appcompat-v7-19.1.0" level="project" /> <orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" /> </component> </module>
這里就有2個facet,第一個是gradule使用的facet,第二個是編譯module時使用的facet。
在使用intellij時,我們有以下的界面配置facet:
可能是facet的功能被gradle代替了,如果你用android studio創建基於gradule的android工程,只有以下的界面:
facet的配置被省略了,如果你想更改,必須到相應的iml文件中去更改。