升级android sdk到5.0,创建项目错误解决方法

来源:互联网 发布:网络劫持金山毒霸 编辑:程序博客网 时间:2024/04/29 20:57

一. ERROR:No resource found that matches the given name 'Theme.AppCompat.Light'

http://www.tuicool.com/articles/YreyEn3


<style name="AppBaseTheme" parent="Theme.AppCompat.Light">

error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.

通过stackoverflow查到其解决方法,如下:

1.

File->Import (android-sdk\extras\android\support\v7). Choose "appcompat"

    

在"文件"中导入sdk路径extras\android\support\v7中的appcompat文件夹.如下图所示:


    2.

Project-> properties->Android.  In  the  section library "Add" and choose "appCompat"

此时问题即可解决,能正确运行.

    问什么会出现这个问题呢?这是我整合“随时拍”项目其他人的代码,他的版本比我的低,

新的eclipse默认模版主题UI需要使用比较高版本api,如果需要支持低版本,需要导入appCompact库来支持.希望文章能解决大家的bug.

二. 导入android-support-v7-appcompat出现问题: android:Widget.Material.ActionButton

http://www.bubuko.com/infodetail-700302.html

[2014-12-03 11:49:13 - android-support-v7-appcompat] E:\my project\android\android-support-v7-appcompat\res\values-v21\styles_base.xml:75: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.ActionButton‘.
[2014-12-03 11:49:13 - android-support-v7-appcompat] E:\my project\android\android-support-v7-appcompat\res\values-v21\themes_base.xml:191: error: Error: No resource found that matches the given name: attr ‘android:colorPrimaryDark‘.
[2014-12-03 11:49:13 - android-support-v7-appcompat]

解决办法:

将文件project.properties中的

target=android-19

改为

target=android-21

后clean

即可解决




http://www.phperz.com/article/14/1204/39233.html

本文向大家讲解的是升级android sdk到5.0,创建项目错误:No resource found that matches the given name 'android:Widget.Material.A 的原因及解决方法,感兴趣的同学参考下。

错误描述:
升级sdk 到5.0时,创建项目时会多创建一个库项目,叫appcompat_v7。
创建完成后,这个项目可能会报错,诸如出现:No resource found that matches the given name 'android:Widget.Material.ActionButton'等错误。
 

解决方案1:

使用sdk manager下载以下内容:
 
 
 
解决方案2:
如果你不想创建appcompat_v7,你可以在创建项目时将minimum Required SDK设置为4.1以上,这时就不再生成
appcompat_v7项目了,然后你再去清单文件中将minSdkVersion还原为8就行了.



三. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.playdemo/com.example.playdemo.DemoActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class android.support.v7.internal.widget.NativeActionModeAwareLayout
解决方法:Java Build Path——Libararies——Add External Jars——选择eclipse-workspace-appcompat_v7-libs-v4和v7两个jar
Java Build Path——order and export中将刚才两个jar打勾。


四. MainActivity出现ActionBarActivity无法识别类
最简单的办法,在创建Android project的时候,Theme选择为Holo Dark就可以了。

0 0