Android的工作室抛出ClassCastException当试图打开一个布局XML文件 [英] Android Studio ClassCastException When Attempting to Open A Layout XML File

查看:1234
本文介绍了Android的工作室抛出ClassCastException当试图打开一个布局XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个模块组成一个Android Studio项目如下所示:

I have an Android Studio project composed of several modules as shown:

项目


  • facebookLibraryModule

  • zxingLibraryModule

  • myLibraryModule

  • applicationModule

myLibraryModule都依赖于Facebook和ZXing和applicationModule取决于myLibraryModule。

myLibraryModule depends on both Facebook and ZXing and applicationModule depends on myLibraryModule.

我能够在斑马线图书馆开放式布局的XML文件(Facebook并没有包含任何),但是当我尝试从任在MyLibrary或应用程序中打开一个布局XML,我得到一个ClassCastException

I am able to open layout XML files in the ZXing library (Facebook doesn't contain any), but when I try to open a layout XML from either myLibrary or the application, I get a ClassCastException

ClassCastException异常:com.intellij.psi.impl.source.PsiPlainTextFileImpl不能转换到com.intellij.psi.xml.XmlFile:com.intellij.psi.impl.source.PsiPlainTextFileImpl不能转换为com.intellij.psi .xml.XmlFile

ClassCastException: com.intellij.psi.impl.source.PsiPlainTextFileImpl cannot be cast to com.intellij.psi.xml.XmlFile: com.intellij.psi.impl.source.PsiPlainTextFileImpl cannot be cast to com.intellij.psi.xml.XmlFile

此外,当我试图创建一个布局文件,

Additionally, when I try to create a layout file,

我得到一个NullPointerException异常

I get a NullPointerException

然而,创建布局文件。尝试打开该文件给出了ClassCastException异常。

however, the layout file is created. Attempting to open the file gives the ClassCastException.

我试图创造其他文本编辑器的布局(记事本,记事本+ +等),并有同样的问题。我已经重新安装了Android的工作室无济于事。我正在测试版0.8.9构建AI-135.1404660,只是检查更新,没有一个是在Beta渠道提供。

I have tried creating the layout in other text editors (Notepad, Notepad++, etc) and have the same problem. I have re-installed Android Studio to no avail. I am running Beta 0.8.9 Build AI-135.1404660 and just checked for updates, none are available in the Beta Channel.

卸载并重新安装Android的工作室,然后手动重建项目。所有布局文件都是很好的,所有可以打开。我关闭了Android的工作室在这一天结束,第二天打开一看,一切都回到具有相同的问题。

Uninstalled and reinstalled Android Studio, then recreated the projects manually. All of the layout files were good and all could be opened. I closed Android Studio at the end of the day and opened it the next day and everything was back to having the same issues.

有什么想法?

推荐答案

不知道你解决与否现在。我使用的是Android 1.0.1工作室和1.0.2也有类似的问题。(得到了相同的 ClassCastException异常打开任何XML文件,不仅布局时)。
在我的情况的问题是由于一个XML文件是过大的原因(有一个警告,XML文件超过256万一套的限制,矿山几乎是9 MB)。从 / RES 文件夹和Android工作室重新启动删除它帮助。

Not sure if you solved it or not by now. I had a similar issue using Android Studio 1.0.1 and 1.0.2.(got the same ClassCastException when opening any XML file, not only layouts). The issue in my case is cause due a XML file being too large (got a warning that the XML file exceeded a set limit of 2560000, mine was almost 9 MB). Removing it from the /res folder and a restart of Android Studio helped.

我希望以上信息有助于一点。

I hope the above info helps a bit.

干杯,

这篇关于Android的工作室抛出ClassCastException当试图打开一个布局XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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