1、因为项目中使用v7包中的布局文件,所以必须导入v7作为库。今天更新了ADT出现各种问题,最终解决了。
2、ADT更新到最新版本,如果更新不了,直接在官网下载最新android ecplice,里面自带了最新的ADT。
http://www.eclipse.org/downloads/packages/eclipse-android-developers-includes-incubating-components/neon1a
3、ecplice设置你的SDK路径,可能提示需要你更新android sdk tools,你可以使用android sdk manager更新platform-tools工具。
做个总结:
1)ecplice工具
2)ADT。
可以单独下载,离线安装,也可以下载最新ecplice里面自带了ADT
3)Android SDK Manager。
打开后设置代理:
mirrors.neusoft.edu.cn
80
更新
Tools工具、下载代码编译的API、镜像、extras v7、v4兼容库。
4、以上都准备好了,ecplice设置好sdk路径,新建一个项目。
1)如果你设置了min sdk<=api13,那个会自动生成
appcompat_v7项目。
最小SDK选在Android4.0 api14以上不会生成这个支持库。
2)作用:
这个库功能是兼容低版本,可以使用
能让2.1以上全使用上4.0版本的界面的支持库
3)通常我们都会兼容低版本手机吧,所以这个库还是有必要,那么问题来了!!!!!
设置minsdk<14,创建的项目全是叉叉!!!!
烦!!!!
一个一个解决吧。
第一步:
首选看库文件,
这个里面完全没有代码,主要是 v4\v7的jar包,
最关键的是它有res目录,里面有很多资源,布局xml,style等文件,我们的项目很多错误就是找不到这里面的引用导致的!!!!
你创建项目会发现这个有个感叹号,吓尿了,你什么都没有改啊!!!别急,打开
应该有库文件不存在,但是勾选了,直接remove就好了。
这个导入之后,其实就是一个库,但是我测试选择项目属性,没有
“Android”这个选项,真他妈坑!!!算了,不管这个。
后来更新ADT到24.0.0.1,离线安装之后,重启正常显示。
所以建议ADT 和sdk platform-tools都是最新版本。
第二步:
看看你创建的项目错误在哪里。
错误1:样式主题没有
我遇到的是提示style样式没找到,其实这个是在v7包里面的,右键选择添加ilb库
选完之后,会发现多了一个android dependencies库
这个就是v7包的java代码转化的.class文件,但是v7没有java代码,所以为空!!!
错误2:android.support.v7包没有找到,
import中有错误。
方法1:点击project-clean,自动生成
android private libraries ,包含v4、v7jar包
方法2:如果1 中build无效,创建libs目录,添加v4\v7,自己手动右击鼠标 and to build path,clean一下就好了。
还有一个坑,就是和你选择的编译API版本有关系,最新的appcompat包中很多属性只有android 5.0 API下才有,所以你选择的编译api必须在>=21以上,否则无法运行,除非你一个一个把高版本的style给删除 或者替换!!!!
错误如下:
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:71: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.ActionButton’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\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.CloseMode’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:80: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.ActionButton.Overflow’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:25: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.ActionBar.TabView’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:29: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.Light.ActionBar.TabView’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:33: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.ActionBar.TabText’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\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-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\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-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:61: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.ActionMode.Title’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\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.Subtitle’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v23\styles_base_text.xml:22: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.ActionBar.Menu’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:45: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.ActionBar.Title’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:49: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.ActionBar.Subtitle’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:53: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.ActionBar.Title.Inverse’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:57: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.ActionBar.Subtitle.Inverse’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:195: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.ProgressBar.Horizontal’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:199: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.ProgressBar’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:110: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.Spinner’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-ldltr-v21\styles_base.xml:26: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.Spinner.Underlined’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v23\styles_base.xml:26: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.Spinner.Underlined’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:107: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.DropDownItem.Spinner’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:114: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.ListView’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:104: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.ListView.DropDown’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:119: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.ListPopupWindow’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:131: error: Error: No resource found that matches the given name: attr ‘android:overlapAnchor’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:136: error: Error: No resource found that matches the given name: attr ‘android:overlapAnchor’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:122: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.PopupMenu’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:125: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.Light.PopupMenu’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:139: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.PopupMenu.Large’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:143: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.PopupMenu.Small’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:147: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.PopupMenu.Large’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:151: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.PopupMenu.Small’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:157: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.SearchResult.Title’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:161: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.SearchResult.Subtitle’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:165: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.AutoCompleteTextView’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:90: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.Toolbar.Button.Navigation’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:94: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.ActionBar.Title’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:98: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.ActionBar.Subtitle’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:169: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.EditText’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:187: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.CompoundButton.CheckBox’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:189: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.CompoundButton.RadioButton’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:64: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Button’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:173: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.RatingBar’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v23\styles_base.xml:22: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.RatingBar.Indicator’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v23\styles_base.xml:24: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.RatingBar.Small’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:175: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.SeekBar’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:177: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.Button’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:179: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.Button.Small’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v23\styles_base.xml:20: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.Button.Colored’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:181: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.Button.Borderless’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:183: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.Button.Borderless.Colored’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:191: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.ImageButton’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:203: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.TextView.SpinnerItem’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:205: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Widget.TextView.SpinnerItem’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base.xml:185: error: Error retrieving parent for item: No resource found that matches the given name ‘android:Widget.Material.ButtonBar’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:20: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:22: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Display4’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:24: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Display3’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:26: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Display2’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:28: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Display1’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:30: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Headline’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:32: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Title’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:34: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Subhead’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:36: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Body2’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:38: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Body1’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:40: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Caption’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:42: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Menu’.
[2016-11-16 18:17:35 - hello1] C:\Users\lihui20\workspace\appcompat_v7\res\values-v21\styles_base_text.xml:60: error: Error retrieving parent for item: No resource found that matches the given name ‘android:TextAppearance.Material.Button’.
[2016-11-16 18:17:35 - hello1]
……
我的编译 用7.0:
target=android-25
android.library.reference.1=../appcompat_v7
有问题大家一起交流,我的qq:973742475
谢谢!