Eclipse Layout Designer 无法打开 IntelliJ 创建的 XML 文件

发布于 2024-11-14 18:42:39 字数 994 浏览 6 评论 0原文

在了解为什么 Eclipse 不想在其布局设计器中打开 XMl 文件后,我希望我们能够在这里解决这个问题。

无论如何,在我在 InteliJ IDEA 中创建项目、以 Eclipse 格式导出它、在 Eclipse 中打开它之后,我意识到 Eclipse 布局设计器无法识别这样的 XML 文件,并且布局设计器无法将其内容加载到设计器的右窗格中。这是我尝试加载 InteliJ 创建的 XML 文件后设计器的样子。

事实上,在将设计器设置为更正 Android 操作系统版本后,我可以加载 Android 布局元素(下拉列表,元素出现在左侧窗格中)设计器),但 XML 文件的内容永远不会加载到设计器的右窗格中。

在检查了 Eclipse 中创建的项目和 IntelliJ 中创建的项目的结构后,我意识到 Eclipse 不会在 /gen 目录中生成 Java 文件,也不会在导入 IntelliJ 创建的项目后导入正确的 Android 库。看图片。

上层项目是在 Eclipse 中创建的,它同时导入了 Android R 文件和 Android 库。 下面的项目是在 IntelliJ 中创建的,导出为 Eclipse 格式,然后导入到 Eclipse 工作区。它没有导入 Android R 文件或 Android 库。

另一个问题是我无法强制重建 Intellij 创建的项目,甚至无法在 Eclipse 中清理它,因为它不在项目列表中。就像 Eclipse 根本不将其视为 Android 项目一样。

最后一个问题是:当我在布局设计器中手动设置 Android 操作系统版本,然后尝试将 Android 元素拖放到设计器的右窗格中时,我收到消息(错误)“缺少项目资源”。看图片。

请帮忙!

After realizing why Eclipse did not want to open XMl files in its Layout designer, I hope we'll be able to solve this issue here.

Anyway, after I create the project in InteliJ IDEA, exports it in Eclipse format, opens it in Eclipse, I realize that Eclipse Layout Designer does not recognize such XML file and the Layout Designer cannot load its content into right pane of the designer. This is how the Designer looks like after I try to load InteliJ-created XML file.

Indeed, I can load Android layout elements after setting Designer to correct Android OS version (dropdown list, elements appear in left pane of the designer), but the very content of the XML file gets never loaded in the right pane of the Designer.

After examining the STRUCTURE of a project created in Eclipse and a project created in IntelliJ, I realized that Eclipse DOES NOT generate Java files in /gen directory nor it imports correct Android library once I import IntelliJ-created project. Look at the image.

The upper project is created in Eclipse and it has both Android R files and Android library imported.
The project below is created in IntelliJ, exported to Eclipse format and then imported into Eclipse workspace. It does not have either Android R files or Android library imported.

Another problem is that I cannot force rebuild the Intellij-created project or even clean it in Eclipse because it isn't in the list of projects. Like Eclipse does not see it as an Android project at all.

The final issue is: when I manually set Android OS version in Layout Designer, then try to grab&drop Android element into the right pane of the Designer, I get the message (error) "Missing project resources". Look at the image.

Please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别闹i 2024-11-21 18:42:39

我没有使用过 IntelliJ IDEA 进行 Android 开发。但据我猜测,我认为存在编码不匹配。文本文件通常采用 UTF-8 编码。但有些编辑器有不同的默认编码,例如:ISO-8859-1。这可能会让 IntelliJ 解析器感到困惑。

如果编码正常,请检查 IntelliJ 是否尝试根据 Android 架构验证 xml 文件。如果找不到架构,那么 IDE 应在日志中报告错误。您可以关闭验证或显示 IntelliJ 的架构路径。

如果您不介意我问,为什么要使用 IntelliJ 而不是 Eclipse?

I've not used IntelliJ IDEA for Android development. But from what I can guess I think there is an encoding mismatch. The text files are typically encoded in UTF-8. But some editors have a different default encoding like: ISO-8859-1. This could be confusing IntelliJ parser.

If the encoding is OK, check whether IntelliJ is trying to validate the xml file against Android schema. If it can't find the schema then the IDE should report the error on the logs. You can either turn off validation or show the schema path to IntelliJ.

If you don't mind me asking, why do you want to use IntelliJ instead of Eclipse?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文