且构网

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

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

更新时间:2023-12-05 12:42:16

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

What are iml files in Android Studio project?

iml文件上进行Google搜索:

A Google search on iml file turns up:

IML是由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 很快就会开始普及,以便也许您可以拥有一个可以从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