• Android Studio中的Module,Facet


    详细内容请参看 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 so Android application projects can reference its source code and resources.

    在用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文件中去更改。

  • 相关阅读:
    redis存储session配制方法
    thanks使用注意事项;
    mongodb sort limit和skip用法
    mongoose的用法(注:连接数据库)
    mongoose查询特定时间段文档的方法
    webworker的使用案例
    js 传参数
    redis.config翻译
    Oracle keep详解
    自学之笔记总结
  • 原文地址:https://www.cnblogs.com/breezemist/p/3757415.html
Copyright © 2020-2023  润新知