如何删除支持库(appcompat_v7)[Eclipse] [英] How to remove support library (appcompat_v7) [Eclipse]

查看:237
本文介绍了如何删除支持库(appcompat_v7)[Eclipse]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我更新了我的eclipse和ADT插件到最新版本,并认识到一些重大变化。每当我创建一个新的Android应用程序项目时,都会出现一个新的appcompat_v7库,它不存在,还有一个fragment_main.xml。这是为什么?为什么activity_main.xml文件不再适用于活动布局,为什么现在每个项目都包含了appcompat库?我试图删除eclipse / adt / sdk很多次,从sdk管理器删除支持库,但没有结果!我知道它与actionbar有关,但问题是,每当我创建一个新项目时,项目文件和appcompat_v7文件都会显示一个红色的感叹号,这样可以防止我编译/运行应用程序,甚至有时候appcompat_v7文件不会 t创建,唯一得到的是损坏代码这里是一张照片: http://i.stack.imgur.com/XJMfW .png



所以如何删除这个依赖关系,谢谢

解决方案


为什么这样?


由于Google工程师将这些内容添加到新活动模板,至少为BlankActivity。


为什么activity_main.xml文件不再适用于活动布局了


无论您想要什么,您当然欢迎使用 activity_main.xml 。所以Google的当前模板希望你使用片段。 Google的模板只是模板。人们可以强烈地反驳 - BlankActivity模板不应该在做它正在做的事情。但是,除此之外,它只是一个模板。


为什么appcompat库现在包含在每个项目中?


大概,他们希望通过一致的操作栏启动您,即使在较旧的API级别。


我意识到它与actionbar有关,但问题是每当我创建一个新项目时,都会在项目的文件和appcompat_v7文件上显示一个红色的感叹号,这样就阻止我编译/运行应用程序甚至有时候appcompat_v7文件不会创建,唯一得到的是损坏的代码


我报告了这个问题一周左右。


所以如何删除这种依赖关系


步骤1:右键单击在Package Explorer中的项目名称,并选择属性。在左侧的属性类别列表中点击Android,然后向右滚动到底部:





步骤2:在现在附加的库项目列表中在属性对话框中看到,您可能会看到类似于上述截图中看到的appcompat_v7_6条目。您的最后一位数字会有所不同,可能是您的红色X代替绿色复选标记。无论如何,如果列表中有appcompat_v7_NNN条目,请单击它,然后单击列表右侧的删除按钮。然后单击确定按钮关闭对话框。



步骤3:在 res / values / styles.xml ,将 AppBaseTheme 的父项从 Theme.AppCompat.Light 更改为 @android:风格/ Theme.Light 。在 res / values-v11 / styles.xml 中,将 AppBaseTheme 的父项从主题更改.AppCompat.Light @android:style / Theme.Holo.Light 。在 rest / values-v14 / styles.xml 中,从主题更改 AppBaseTheme 的父级。 AppCompat.Light.DarkActionBar to @android:style / Theme.Holo.Light.DarkActionBar 。请注意,这些值假设您在创建项目时选择了默认的Light theme with dark action bar - 您将需要对其他任何指令进行微调。



步骤#4:在 res / menu / main / xml 中,删除 xmlns:app =http://schemas.android。 com / apk / res-auto从根< menu> 元素和应用程序:showAsAction =从不属性来自< item> 元素。



步骤5:您的活动(例如, MainActivity ),将活动的父类更改为 ActionBarActivity - FragmentActivity 将是一个不错的选择,以最小化您将立即进行的其他更改的数量。此外,清理您的导入(例如, Ctrl-Shift-O )。



此时,除了清理您的项目(Project>从主菜单中清除), appcompat 的东西应该从使用BlankActivity模板创建的项目和导航类型为无中删除。 BlankActivity模板上的其他模板或导航选项可能需要更多的工作。


I've updated my eclipse and ADT Plugin to the latest version recently and recognised some big changes. Whenever I create a new Android Application Project there appears a new appcompat_v7 library which wasn't present before and also a fragment_main.xml . Why is that? Why is the activity_main.xml file not preferred for activity layout directly anymore and why appcompat library is now included in every project ? I tried to remove eclipse/adt/sdk many times and remove the support library from sdk manager but got no result ! I realize it has something to do with actionbar but the problem is that whenever I create a new project a red exclamation mark shows up on both project's file and appcompat_v7 file and this prevents me from compiling/running the application or even sometimes appcompat_v7 file doesn't create and the only thing I get is damaged code here's a picture :http://i.stack.imgur.com/XJMfW.png

so how can I remove this dependency and thanks

解决方案

Why is that?

Because Google engineers added that stuff to the new-activity templates, for at least the "BlankActivity".

Why is the activity_main.xml file not preferred for activity layout directly anymore

You are certainly welcome to use activity_main.xml for whatever you want. It so happens that Google's current templates want you to use fragments. Google's templates are just templates. One can argue -- and I have, vehemently -- that a "BlankActivity" template should not be doing what it is doing. However, beyond that, it is just a template.

why appcompat library is now included in every project ?

Presumably, they wanted to start you off with a consistent action bar, even on older API levels.

I realize it has something to do with actionbar but the problem is that whenever I create a new project a red exclamation mark shows up on both project's file and appcompat_v7 file and this prevents me from compiling/running the application or even sometimes appcompat_v7 file doesn't create and the only thing I get is damaged code

I reported this issue a week or so ago.

so how can I remove this dependency

Step #1: Right-click over the project name in the Package Explorer, and choose Properties. Click on Android in the list of property categories on the left, and scroll down on the right to the bottom:

Step #2: In the list of attached library projects that you will now see in the properties dialog, you may see an entry akin to the "appcompat_v7_6" one that you see in the above screenshot. Your last digit will differ, and it may be that yours has a red X instead of a green checkmark. Regardless, if there is an entry for "appcompat_v7_NNN" in the list, click on it, then click the Remove button to the right of the list. Then, click the OK button to close up the dialog.

Step #3: In res/values/styles.xml, change the parent of AppBaseTheme from Theme.AppCompat.Light to @android:style/Theme.Light. In res/values-v11/styles.xml, change the parent of AppBaseTheme from Theme.AppCompat.Light to @android:style/Theme.Holo.Light. In rest/values-v14/styles.xml change the parent of AppBaseTheme from Theme.AppCompat.Light.DarkActionBar to @android:style/Theme.Holo.Light.DarkActionBar. Note that these values assume that you chose the default "Light theme with dark action bar" when you created the project -- you will need to make slight adjustments to those instructions for anything else.

Step #4: In res/menu/main/xml, remove xmlns:app="http://schemas.android.com/apk/res-auto" from the root <menu> element and the app:showAsAction="never" attribute from the <item> element.

Step #5: In your activity (e.g., MainActivity), change the parent class of the activity to something other than ActionBarActivity -- FragmentActivity would be a good choice, to minimize the number of other changes you will have to make immediately. Also, clean your imports (e.g., Ctrl-Shift-O).

At this point, other than perhaps cleaning your project (Project > Clean from the main menu), the appcompat stuff should be ripped out of a project created using the "BlankActivity" template and with a "Navigation Type" of "None". Other templates, or navigation options on the "BlankActivity" template, will probably require more work.

这篇关于如何删除支持库(appcompat_v7)[Eclipse]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆