avast / android-butterknife-zelezny

Android Studio plug-in for generating ButterKnife injections from selected layout XML.
Apache License 2.0
3.38k stars 412 forks source link

Android ButterKnife Zelezny threw an uncaught ArrayIndexOutOfBoundsException. #124

Open mail2bhramar opened 7 years ago

mail2bhramar commented 7 years ago

java.lang.ArrayIndexOutOfBoundsException: 0 at com.avast.android.butterknifezelezny.model.Element.getFieldName(Element.java:81) at com.avast.android.butterknifezelezny.model.Element.(Element.java:43) at com.avast.android.butterknifezelezny.common.Utils$1.visitElement(Utils.java:195) at com.intellij.psi.XmlElementVisitor.visitXmlElement(XmlElementVisitor.java:22) at com.intellij.psi.XmlElementVisitor.visitXmlTag(XmlElementVisitor.java:54) at com.intellij.psi.impl.source.xml.XmlTagImpl.accept(XmlTagImpl.java:1076) at com.intellij.psi.impl.source.tree.CompositePsiElement.acceptChildren(CompositePsiElement.java:81) at com.intellij.psi.XmlRecursiveElementVisitor.visitElement(XmlRecursiveElementVisitor.java:37) at com.avast.android.butterknifezelezny.common.Utils$1.visitElement(Utils.java:157) at com.intellij.psi.XmlElementVisitor.visitXmlElement(XmlElementVisitor.java:22) at com.intellij.psi.XmlElementVisitor.visitXmlTag(XmlElementVisitor.java:54) at com.intellij.psi.impl.source.xml.XmlTagImpl.accept(XmlTagImpl.java:1076) at com.intellij.psi.impl.source.tree.CompositePsiElement.acceptChildren(CompositePsiElement.java:81) at com.intellij.psi.XmlRecursiveElementVisitor.visitElement(XmlRecursiveElementVisitor.java:37) at com.avast.android.butterknifezelezny.common.Utils$1.visitElement(Utils.java:157) at com.intellij.psi.XmlElementVisitor.visitXmlElement(XmlElementVisitor.java:22) at com.intellij.psi.XmlElementVisitor.visitXmlTag(XmlElementVisitor.java:54) at com.intellij.psi.impl.source.xml.XmlTagImpl.accept(XmlTagImpl.java:1076) at com.intellij.psi.impl.source.tree.CompositePsiElement.acceptChildren(CompositePsiElement.java:81) at com.intellij.psi.XmlRecursiveElementVisitor.visitElement(XmlRecursiveElementVisitor.java:37) at com.avast.android.butterknifezelezny.common.Utils$1.visitElement(Utils.java:157) at com.intellij.psi.XmlElementVisitor.visitXmlElement(XmlElementVisitor.java:22) at com.intellij.psi.XmlElementVisitor.visitXmlTag(XmlElementVisitor.java:54) at com.intellij.psi.impl.source.xml.XmlTagImpl.accept(XmlTagImpl.java:1076) at com.intellij.psi.impl.source.tree.CompositePsiElement.acceptChildren(CompositePsiElement.java:81) at com.intellij.psi.XmlRecursiveElementVisitor.visitElement(XmlRecursiveElementVisitor.java:37) at com.avast.android.butterknifezelezny.common.Utils$1.visitElement(Utils.java:157) at com.intellij.psi.XmlElementVisitor.visitXmlElement(XmlElementVisitor.java:22) at com.intellij.psi.XmlElementVisitor.visitXmlDocument(XmlElementVisitor.java:42) at com.intellij.psi.impl.source.xml.XmlDocumentImpl.accept(XmlDocumentImpl.java:90) at com.intellij.psi.impl.source.tree.SharedImplUtil.acceptChildren(SharedImplUtil.java:199) at com.intellij.psi.impl.source.PsiFileImpl.acceptChildren(PsiFileImpl.java:820) at com.intellij.psi.XmlRecursiveElementVisitor.visitElement(XmlRecursiveElementVisitor.java:37) at com.avast.android.butterknifezelezny.common.Utils$1.visitElement(Utils.java:157) at com.intellij.psi.PsiElementVisitor.visitFile(PsiElementVisitor.java:34) at com.intellij.psi.XmlRecursiveElementVisitor.visitFile(XmlRecursiveElementVisitor.java:55) at com.intellij.psi.XmlElementVisitor.visitXmlFile(XmlElementVisitor.java:26) at com.intellij.psi.impl.source.xml.XmlFileImpl.accept(XmlFileImpl.java:71) at com.avast.android.butterknifezelezny.common.Utils.getIDsFromLayout(Utils.java:153) at com.avast.android.butterknifezelezny.common.Utils.getIDsFromLayout(Utils.java:143) at com.avast.android.butterknifezelezny.InjectAction.actionPerformedImpl(InjectAction.java:69) at com.avast.android.butterknifezelezny.InjectAction.actionPerformed(InjectAction.java:56) at com.intellij.ui.popup.PopupFactoryImpl$ActionPopupStep.performAction(PopupFactoryImpl.java:861) at com.intellij.ui.popup.PopupFactoryImpl$ActionPopupStep$1.run(PopupFactoryImpl.java:847) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:726) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:857) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:658) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:386) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

mitsest commented 7 years ago

This is happening for me too.

Any solutions?

siempredelao commented 7 years ago

@mail2bhramar, @mitsest, any info about how did you get this error would be appreciated :wink:

mitsest commented 7 years ago

hi @siempredelao and thanks for the fast reply!

It seems my issue was the same with this : https://github.com/avast/android-butterknife-zelezny/issues/40

When I removed the double underscore, the exception disappeared.

I would strongly suggest allowing double underscore in ids though, as they tend to get pretty long e.g. fragment_my_account_payment_methods_title_first. fragment_my_account__payment_methods__title_first is more readable, no?

Ah well, I should stop now!

Thanks again for the plugin :)

TomasKypta commented 7 years ago

Double underscore issue should have been resolved long time ago. It's probably a reintroduced bug.

JImmyBhavsar commented 6 years ago

It was "__" added in textview id. I had removed it and the plugin was working fine to add dependencies.