我尝试将项目导入eclipse,但我在res / values / styles.xml中发现了一个问题。这就是我在控制台中收到的内容:
[2015-12-12 13:01:04 - AllInOne] D:\tpandroid\AllInOne\res\values\styles.xml:13: error: A 'name' attribute is required for <item>
[2015-12-12 13:01:04 - AllInOne]
[2015-12-12 13:01:04 - AllInOne] D:\tpandroid\AllInOne\res\values\styles.xml:19: error: A 'name' attribute is required for <item>
[2015-12-12 13:01:04 - AllInOne]
[2015-12-12 13:01:04 - AllInOne] D:\tpandroid\AllInOne\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
[2015-12-12 13:01:04 - AllInOne]
[2015-12-12 13:01:04 - AllInOne] D:\tpandroid\AllInOne\res\values\styles.xml:13: error: Error: Resource id cannot be an empty string: attr ''.
[2015-12-12 13:01:04 - AllInOne]
[2015-12-12 13:01:04 - AllInOne] D:\tpandroid\AllInOne\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
[2015-12-12 13:01:04 - AllInOne]
[2015-12-12 13:01:04 - AllInOne] D:\tpandroid\AllInOne\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
[2015-12-12 13:01:04 - AllInOne]
[2015-12-12 13:01:04 - AllInOne] D:\tpandroid\AllInOne\res\values\styles.xml:19: error: Error: Resource id cannot be an empty string: attr ''.
[2015-12-12 13:01:04 - AllInOne]
那是styles.xml:
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
<item />
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item />
</style>
</resources>
答案 0 :(得分:1)
错误意味着不允许<item />
。它必须是<item name="..." />
。
答案 1 :(得分:1)
错误表示您尝试在样式文件中声明没有name
标记的项目。例如,您可能只是打开了一个项目标签并将其关闭如下:
<item>
</item>
要解决此问题,请将“name”添加到item标记中,例如它应如下所示:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CodeFont" parent="@android:style/TextAppearance.Medium">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>
请参阅上面的强制name
属性。检查the docs。
答案 2 :(得分:0)
实际上在我的情况下,错误显示为文件values.xml,这是一个构建文件,因此无法更改它。实际的错误在style.xml文件中