且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android Studio 中的 .iml 文件是什么?

更新时间:2023-12-05 11:58:58

Android Studio 项目中的 iml 文件是什么?

What are iml files in Android Studio project?

出现对 iml 文件 的 Google 搜索:

A Google search on iml file turns up:

IML 是由 IntelliJ IDEA 创建的模块文件,IntelliJ IDEA 是一个用于开发 Java 应用程序的 IDE.它存储有关开发模块的信息,这些模块可能是 Java、Plugin、Android 或 Maven 组件;保存模块路径、依赖项和其他设置.

IML is a module file created by IntelliJ IDEA, an IDE used to develop Java applications. It stores information about a development module, which may be a Java, Plugin, Android, or Maven component; saves the module paths, dependencies, and other settings.

(来自本页)

为什么不使用 gradle 脚本与您添加到项目中的外部模块集成.

why not to use gradle scripts to integrate with external modules that you add to your project.

您确实使用 gradle 脚本与外部模块集成",或者您自己的模块.

You do "use gradle scripts to integrate with external modules", or your own modules.

然而,Gradle 并不是 IntelliJ IDEA 的原生项目模型——这是独立的,保存在 .iml 文件中,元数据保存在 .idea/ 目录中.在 Android Studio 中,这些东西主要是由 Gradle 构建脚本生成的,这就是为什么当您更改诸如 build.gradle 之类的文件时,有时会提示您将项目与 Gradle 文件同步".这也是为什么您不必费心将 .iml 文件或 .idea/ 放在版本控制中的原因,因为它们的内容将被重新生成.

However, Gradle is not IntelliJ IDEA's native project model — that is separate, held in .iml files and the metadata in .idea/ directories. In Android Studio, that stuff is largely generated out of the Gradle build scripts, which is why you are sometimes prompted to "sync project with Gradle files" when you change files like build.gradle. This is also why you don't bother putting .iml files or .idea/ in version control, as their contents will be regenerated.

如果我有一个团队在不同的 IDE 中工作,例如 Eclipse 和 AS,如何使项目 IDE 不可知?

If I have a team that work in different IDE's like Eclipse and AS how to make project IDE agnostic?

在很大程度上,你不能.

To a large extent, you can't.

欢迎您拥有一个使用 Eclipse 风格目录结构的 Android 项目(例如,项目根目录中的资源和清单).您可以通过 build.gradle 教 Gradle 如何在该结构中查找文件.但是,其他元数据(compileSdkVersion、依赖项等)几乎不会轻易复制.

You are welcome to have an Android project that uses the Eclipse-style directory structure (e.g., resources and manifest in the project root directory). You can teach Gradle, via build.gradle, how to find files in that structure. However, other metadata (compileSdkVersion, dependencies, etc.) will not be nearly as easily replicated.

其他替代方案包括:

  • 将每个人转移到另一个构建系统,如 Maven,它同样集成(或不集成,取决于您的观点)到 Eclipse 和 Android Studio

  • Move everybody over to another build system, like Maven, that is equally integrated (or not, depending upon your perspective) to both Eclipse and Android Studio

希望 Andmore 尽快起飞,这样也许您就可以拥有一个 Eclipse IDE从 Gradle 构建脚本构建 Android 项目

Hope that Andmore takes off soon, so that perhaps you can have an Eclipse IDE that can build Android projects from Gradle build scripts

让每个人都使用一个 IDE

Have everyone use one IDE