自从我在Eclipse中将ADT插件更新到v1.21后,我无法再在Android项目中轻松打开任何XML布局文件。一旦我点击该文件,它就会抛出NullPointerException。以下是错误日志中的堆栈跟踪:
java.lang.NullPointerException
at com.android.ide.eclipse.adt.internal.editors.common.CommonMatchingStrategy.matches(CommonMatchingStrategy.java:59)
at org.eclipse.ui.internal.WorkbenchPage.checkEditor(WorkbenchPage.java:2254)
at org.eclipse.ui.internal.WorkbenchPage.findEditors(WorkbenchPage.java:2223)
at org.eclipse.ui.internal.WorkbenchPage.findEditor(WorkbenchPage.java:2205)
at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.isOpenInEditor(EditorUtility.java:131)
at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.linkToEditor(PackageExplorerPart.java:929)
at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.access$2(PackageExplorerPart.java:926)
at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4.linkToEditor(PackageExplorerPart.java:533)
at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.selectionChanged(OpenAndLinkWithEditorHelper.java:57)
at org.eclipse.jface.viewers.StructuredViewer$3.run(StructuredViewer.java:888)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.viewers.StructuredViewer.firePostSelectionChanged(StructuredViewer.java:886)
at org.eclipse.jface.viewers.StructuredViewer.handlePostSelect(StructuredViewer.java:1226)
at org.eclipse.jface.viewers.StructuredViewer$5.widgetSelected(StructuredViewer.java:1251)
at org.eclipse.jface.util.OpenStrategy.firePostSelectionEvent(OpenStrategy.java:262)
at org.eclipse.jface.util.OpenStrategy.access$5(OpenStrategy.java:256)
at org.eclipse.jface.util.OpenStrategy$3.run(OpenStrategy.java:433)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4144)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1029)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:923)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
如果我右键单击该文件,我可以打开该文件,并告诉它使用Legacy Android Layout编辑器打开,但这显然不是一个好的解决方案。我尝试进入Eclipse首选项,并确保正确设置了XML文件的文件关联。
答案 0 :(得分:6)
我通过关闭编辑器中的所有打开的项目文件并重新启动Eclipse来解决这个问题。
答案 1 :(得分:0)
我切换到新工作区,然后一切正常。