Android Studio ClassCastException when trying to open layout XML file

I have an Android Studio project made up of multiple modules as shown:

Project

  • facebookLibraryModule
  • zxingLibraryModule
  • myLibraryModule
  • applicationModule

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

I can open layout XML files in ZXing library (Facebook does not contain) but when I try to open layout XML from myLibrary or application I get ClassCastException

ClassCastException: com.intellij.psi.impl.source.PsiPlainTextFileImpl cannot be added to com.intellij.psi.xml.XmlFile: com.intellij.psi.impl.source.PsiPlainTextFileImpl cannot be passed com.intellij.psi.pl. .XmlFile

Also, when I try to create a layout file,

Layout Creation Dialog

I am getting NullPointerException

Null Pointer Exception Dialog

however, a layout file is generated. Trying to open the file gives a ClassCastException.

I tried to create the layout in other text editors (Notepad, Notepad ++, etc.) and had 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 checking for updates, none of them are available in the beta channel.

Removed and reinstalled Android Studio and then recreated the projects manually. All layout files were good and everything could be opened. I closed Android studio at the end of the day and reopened it the next day and everything was back to the same problems.

Any thoughts?

+3


source to share


1 answer


Not sure if you have solved this or not. I had a similar problem using Android Studio 1.0.1 and 1.0.2 (got the same ClassCastException

when opening any XML file, not just layouts). The problem in my case is because the XML file is too large (got a warning that the XML file has exceeded the set limit of 2560000, mine was almost 9 MB). Removing from the folder /res

and restarting Android Studio did the trick.

I hope the above information helps a little.



Greetings,

+2


source







All Articles