解析XML时出错:文档元素之后的垃圾 - 构建图标包

时间:2015-02-26 16:15:40

标签: android xml eclipse adt eclipse-adt

我目前正在Eclipse中创建一个免费的Material Design Icon Pack,后面是[this] [1]教程(我没有太多的编码经验)。在我将一些我的图标添加到applifter.xml并在iconpack.xml中声明它后,我在尝试构建它时遇到此错误:

[2015-02-26 16:10:35 - Materialism] C:\Users\...\workspace\Materialism\res\values\iconpack.xml:10: error: Error parsing XML: junk after document element
[2015-02-26 16:10:35 - Materialism] 
[2015-02-26 16:10:35 - Materialism] C:\Users\...\workspace\Materialism\res\xml\appfilter.xml:12: error: Error parsing XML: junk after document element
[2015-02-26 16:10:35 - Materialism] 
[2015-02-26 16:12:30 - Materialism] Error in an XML file: aborting build.

它说“根文档后面的文档中的标记必须形成良好”

这是我的applifter.xml:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <iconback img1="iconback" />
    <iconmask img1="iconmask" />
    <iconupon img1="iconupon" />
    <scale factor="1.1" />

    <!-- Browser -->
    <item component="ComponentInfo{com.android.browser/com.android.browser.BrowserActivity}" drawable="com_android_browser_browseractivity" />
    <item component="ComponentInfo{com.google.android.browser/com.android.browser.BrowserActivity}" drawable="com_android_browser_browseractivity" />
</resources>
    <item component="ComponentInfo{com.djit.bassboostforandroidpro/com.djit.bassboost.MainActivity}" drawable="bassbooster"       
    <item component="ComponentInfo{com.devhd.feedly/com.devhd.feedly.Main}" drawable="feedly"        
    <item component="ComponentInfo{com.rhapsody.napster/com.rhapsodycore.SplashScreen}" drawable="napster"
    <item component="ComponentInfo{com.netflix.mediaclient/com.netflix.mediaclient.UIWebViewActivity}" drawable="netflix"
    <item component="ComponentInfo{com.android.stk/com.android.stk.StkMenuActivity}" drawable="simtoolkit"
    <item component="ComponentInfo{com.snapchat.android/com.snapchat.android.LandingPageActivity}" drawable="snapchat"
    <item component="ComponentInfo{com.rarlab.rar/com.rarlab.rar.MainActivity}" drawable="rar"
    <item component="ComponentInfo{com.keramidas.TitaniumBackup/com.keramidas.TitaniumBackup.MainActivity}" drawable="titaniumbackup"                            

和iconpack.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string-array name="icon_pack" translatable="false">
        <item>com_android_browser_browseractivity</item>
    </string-array>

</resources>

    <string-array name="icon_pack" translatable="false">
        <item>bassbooster</item>
    </string-array>
    <string-array name="icon_pack" translatable="false">
        <item>feedly</item>
    </string-array>    
    <string-array name="icon_pack" translatable="false">
        <item>napster</item>
    </string-array>  
    <string-array name="icon_pack" translatable="false">
        <item>netflix</item>
    </string-array>  
    <string-array name="icon_pack" translatable="false">
        <item>rar</item>
    </string-array>
    <string-array name="icon_pack" translatable="false">
        <item>simtoolkit</item>
    </string-array>

我该如何解决这个问题?

提前感谢:-)

1 个答案:

答案 0 :(得分:0)

XML文件具有严格定义的结构,您必须遵循该结构。在这种情况下,一切都必须在

之间
<resources>

  .... everything must be here ....

</resources>

标记。在</resources>之后放置任何内容都会导致“格式错误”#39; (<?xml version="1.0" encoding="utf-8"?>是例外,必须是第一个。)

还有一些

<item component="ComponentInfo{com.djit.bassboostforandroidpro/com.djit.bassboost.MainActivity}" drawable="bassbooster"       

值不能正确结束。每个项目末尾必须有/> - 如下所示:

<item component="ComponentInfo{com.djit.bassboostforandroidpro/com.djit.bassboost.MainActivity}" drawable="bassbooster" />