创建项目自动生成了appcompat_v7项目,然而appcompat_v7报错:
[2016-12-31 20:10:56 - V7Test] D:\EclipseWorkspace\test\appcompat_v7\res\values-v21\styles_base.xml:37: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.[2016-12-31 20:10:56 - V7Test][2016-12-31 20:10:56 - V7Test] D:\EclipseWorkspace\test\appcompat_v7\res\values-v21\styles_base.xml:41: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.[2016-12-31 20:10:56 - V7Test][2016-12-31 20:10:56 - V7Test] D:\EclipseWorkspace\test\appcompat_v7\res\values-v21\styles_base.xml:65: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Title'.
...
类似上面的很多错误,其实这个问题很简单,但是网上的很多帖子解决方法都不对,或者凑巧对了,但是解释不对。
解决方法:
右键你导入的android-support-v7-appcompat—>properties—>选择左侧栏Android—>在project bulid target中选择api21以上的—>clean即可。
或者
将AndroidManifest.xml和project.properties.xml文件中的targetSdkVersion和target改为android-21或更高即可。
原因:
创建项目时有“编译用SDK版本”(compile with)的选项,编译版本是19,19没有包含21的一些选项,所以把编译版本改成5.0 就可以了。所以:只用改 编译版本,不用改 target SDK版本 也可以!!