Android Studio 中的 .iml 文件是什么? [英] What are .iml files in Android Studio?

查看:84
本文介绍了Android Studio 中的 .iml 文件是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android Studio 项目中的 .iml 文件是什么?我读到它是模块的配置文件.我不明白它是如何工作的,我不能只使用 gradle 脚本与您添加到项目中的外部模块集成.

What are .iml files in Android Studio project? I read that it is configuration file for modules. I do not understand how it works, and can't I just use gradle scripts to integrate with external modules that you add to your project.

此外,大部分时间 AS 都会生成它们,因此我无法控制项目行为.如果我的团队在 Eclipse 和 AS 等不同的 IDE 中工作,是否可以设置我的项目使其与 IDE 无关?

Also, most of the time AS generates them, so I cannot control project behaviour. If I have a team that works in different IDEs like Eclipse and AS, is it possible to setup my project so it's IDE agnostic?

我不完全理解这个系统是如何工作的.

I don't fully understand how this system works.

推荐答案

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

这篇关于Android Studio 中的 .iml 文件是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆