2

我无法将新活动添加到我的项目中。在“添加活动”向导结束时,如果我单击完成按钮,向导仍会打开并且只更改清单文件。

我正在使用 Android 开发者工具构建:v22.0.0-675183

来自 Eclipse 的错误 (android\.metadata\.log)

!ENTRY com.android.ide.eclipse.adt 4 0 2013-06-02 14:46:09.807
!MESSAGE 
!STACK 0
java.lang.reflect.InvocationTargetException
    at com.android.ide.eclipse.adt.internal.wizards.templates.TemplateWizard.performFinish(TemplateWizard.java:164)
    at com.android.ide.eclipse.adt.internal.wizards.templates.TemplateWizard$1.run(TemplateWizard.java:188)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: org.eclipse.core.runtime.CoreException: End position lies outside document range
    at org.eclipse.ltk.internal.core.refactoring.Changes.asCoreException(Changes.java:62)
    at org.eclipse.ltk.core.refactoring.TextChange.perform(TextChange.java:246)
    at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
    at com.android.ide.eclipse.adt.internal.wizards.templates.TemplateWizard.performFinish(TemplateWizard.java:161)
    ... 2 more
Caused by: org.eclipse.text.edits.MalformedTreeException: End position lies outside document range
    at org.eclipse.text.edits.TextEditProcessor.checkIntegrityDo(TextEditProcessor.java:178)
    at org.eclipse.text.edits.TextEdit.dispatchCheckIntegrity(TextEdit.java:743)
    at org.eclipse.text.edits.TextEditProcessor.performEdits(TextEditProcessor.java:151)
    at org.eclipse.ltk.core.refactoring.TextChange.performEdits(TextChange.java:277)
    at org.eclipse.ltk.core.refactoring.TextFileChange.performEdits(TextFileChange.java:262)
    at org.eclipse.ltk.core.refactoring.TextChange.perform(TextChange.java:238)
    ... 4 more
Root exception:
    org.eclipse.core.runtime.CoreException: End position lies outside document range
            at org.eclipse.ltk.internal.core.refactoring.Changes.asCoreException(Changes.java:62)
            at org.eclipse.ltk.core.refactoring.TextChange.perform(TextChange.java:246)
            at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
            at com.android.ide.eclipse.adt.internal.wizards.templates.TemplateWizard.performFinish(TemplateWizard.java:161)
            at com.android.ide.eclipse.adt.internal.wizards.templates.TemplateWizard$1.run(TemplateWizard.java:188)
            at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
        Caused by: org.eclipse.text.edits.MalformedTreeException: End position lies outside document range
            at org.eclipse.text.edits.TextEditProcessor.checkIntegrityDo(TextEditProcessor.java:178)
            at org.eclipse.text.edits.TextEdit.dispatchCheckIntegrity(TextEdit.java:743)
            at org.eclipse.text.edits.TextEditProcessor.performEdits(TextEditProcessor.java:151)
            at org.eclipse.ltk.core.refactoring.TextChange.performEdits(TextChange.java:277)
            at org.eclipse.ltk.core.refactoring.TextFileChange.performEdits(TextFileChange.java:262)
            at org.eclipse.ltk.core.refactoring.TextChange.perform(TextChange.java:238)
            ... 4 more

我究竟做错了什么?

4

2 回答 2

2

我只是有同样的效果。解决方案是文件'strings.xml',它有一个错误的字符编码(不是UTF-8 - 我用Eclipse之外的编辑器编辑了'strings.xml',它以错误的编码保存它)。

使用“strings.xml”的备份(仍然是 UTF-8 编码)并在 Eclipse 中进行编辑,确实解决了问题。

我通过在“要执行的更改”下的“活动向导”预览中单击它找到了错误的文件。

于 2013-08-18T14:19:48.827 回答
1

添加新活动时我遇到了同样的问题。

使用 -command 启动 eclipse-clean没有任何效果,所以我尝试使用 Notepad++ 将 XML 文件从UTF-8转换为UTF8 而没有 BOM。这对我有用。我对每个 XML 文件都这样做了,所以清单layout.xmldimens.xmlstrings.xml.

于 2014-10-23T08:55:57.817 回答