eclipse lib 支持 appcompat_v7 时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26453942/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:05:26  来源:igfitidea点击:

Error at lib support appcompat_v7

androideclipseandroid-support-library

提问by lcsvcn

I am having trouble to at library appcompat_v7

我在图书馆 appcompat_v7 遇到问题

It have error on path

它在路径上有错误

res/values-v21/styles_base.xml

res/values-v21/styles_base.xml

and at line 75 show error - below 75 to 78:

并在第 75 行显示错误 - 低于 75 到 78:

<style name="Base.Widget.AppCompat.ActionButton"
          parent="android:Widget.Material.ActionButton">
 </style>
<style name="Base.Widget.AppCompat.ActionButton"
          parent="android:Widget.Material.ActionButton">
 </style>

at console:

在控制台:

home/user/workspace/appcompat_v7/res/values-v21/themes_base.xml:156: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.

home/user/workspace/appcompat_v7/res/values-v21/themes_base.xml:156: 错误:错误:未找到与给定名称匹配的资源:attr 'android:colorControlNormal'。

and several error similares changing just the 'android:*'

和几个类似的错误只改变了“android:*”

How can I fix this?

我怎样才能解决这个问题?

采纳答案by Raul Pinto

Ok, I'm not sure, if this a real "solution" but here is my theory and what I did:

好吧,我不确定这是否是一个真正的“解决方案”,但这是我的理论和我所做的:

My Theory

我的理论

After updating the "Android Support Library" version 21, I got a similar error. It seems, my IntelliJ didn't update the resources in my module correctly, which pointed to the ressources directory for appcompat.

更新“Android 支持库”版本 21 后,出现类似错误。看来,我的 IntelliJ 没有正确更新我模块中的资源,它指向 appcompat 的 ressources 目录。

Furthermore, I had some widgets and Code that directly pointed to drawables in those ressources.

此外,我有一些小部件和代码直接指向这些资源中的可绘制对象。

But in v21 of the Android Support Library Google dropped support for the Holo theme!

但是在 Android 支持库的 v21 中,谷歌放弃了对 Holo 主题的支持

Hence, the compiler complains about not finding the resources my theme depends on.

因此,编译器抱怨找不到我的主题所依赖的资源。

What I did

我做了什么

When it compiled

当它编译

To be honest, I'm not really sure in how I came out making this work. I guess, I used did some restarting and cache emptying etc. Copying ressources to my project's folder etc. When my app finally started, it looked different! Of course, it had the Materialtheme instead of the Holotheme.

老实说,我不太确定我是如何完成这项工作的。我想,我使用了一些重新启动和缓存清空等。将资源复制到我的项目文件夹等。当我的应用程序最终启动时,它看起来不一样了!当然,它有Material主题而不是Holo主题。

And not everything survived this transition. E.g. the Action Bar was black (standard) instead of green (my theme). So I tried to go back to an old version of appcompat instead of migrating my whole app to Material.

并不是所有的东西都能在这次转变中幸存下来。例如,操作栏是黑色(标准)而不是绿色(我的主题)。所以我尝试回到旧版本的 appcompat,而不是将我的整个应用程序迁移到 Material。

Since you asked me for my solution, I'm posting what I did to "downgrade" to appcompat v20.

既然您问我的解决方案,我将发布我为“降级”到 appcompat v20 所做的工作。

Downgrading to appcompat v20

降级到 appcompat v20

  1. Start SDK Manager
  2. Download Android Support Repository
  3. Go to directory \android-sdk\extras\android\m2repository\com\android\support\appcompat-v7\20.0.0\ where Android SDK is installed
  4. Extract all files from appcompat-v7-20.0.0.aar(it's a zip file) to libs\appcompat\directory in my project, after I created the directory appcompat
  5. Added these as a module in my IntelliJ and made my project depend on this module
  6. Recovered android-support-v7-appcompat.jarfor v20 from my git repository
  7. Used the recovered appcompat jar instead of the v21 one
  1. 启动 SDK 管理器
  2. 下载Android 支持库
  3. 转到安装 Android SDK 的目录 \android-sdk\extras\android\m2repository\com\android\support\appcompat-v7\20.0.0\
  4. 创建目录后,将所有文件appcompat-v7-20.0.0.aar(它是一个 zip 文件)提取到libs\appcompat\我的项目中的目录appcompat
  5. 在我的 IntelliJ 中添加这些作为模块并使我的项目依赖于这个模块
  6. android-support-v7-appcompat.jar从我的 git 存储库中恢复v20
  7. 使用恢复的 appcompat jar 而不是 v21 的

Step 6 is the one, I found very difficult. I expected the classes.jarfrom the .aar file to be the android-support-v7-appcompat.jar, but it wasn't. I even don't know, where you can get the android-support-v7-appcompat.jarfrom in the right version because I didn't find it in the repository. And I didn't want to download it from "somewhere in the internet".

第 6 步是第一个,我发现非常困难。我希望classes.jar.aar 文件中的 是android-support-v7-appcompat.jar,但事实并非如此。我什至不知道你可以android-support-v7-appcompat.jar从哪里获得正确版本的,因为我没有在存储库中找到它。我不想从“互联网的某个地方”下载它。

I was "lucky", it already was in my git in the correct version.

我很“幸运”,它已经在我的 git 中以正确的版本存在。

Now my app compiled and looked correctly. Hope so does yours!

现在我的应用程序编译并正确显示。希望你的也一样!

回答by AdamantMind

Had same problem after upgrading my Eclipse and import "Android Support Library" in workspace.

升级我的 Eclipse 并在工作区中导入“Android 支持库”后遇到同样的问题。

I think it's a bad solution to "Downgrading to appcompat" so I tried to find another way and found it. My problem was that my "Project Build Target" of AppCompat was set to API lvl 19. So this is a problem:

我认为“降级到appcompat”是一个糟糕的解决方案,所以我试图找到另一种方法并找到了它。我的问题是我的 AppCompat 的“项目构建目标”设置为 API lvl 19。所以这是一个问题:

-Eclipse wasn't load the data for API lvl 21 for AppCompat.

-Appcompat have Target API lvl 19, but trying to set style for API lvl 21.

-Eclipse 没有为 AppCompat 加载 API lvl 21 的数据。

-Appcompat 具有 Target API lvl 19,但尝试为 API lvl 21 设置样式。

Maybe You have same problem so checkout what was help me:

也许您有同样的问题,因此请查看对我有帮助的内容:

1.

1.

Right click on Appcompat project => Properties => Android => Checkout where was your mark, and if it's not set on Android 5.0 - fix it and click ok.

右键单击 Appcompat 项目 => 属性 => Android => 签出您的标记在哪里,如果未在 Android 5.0 上设置 - 修复它并单击确定。

2.

2.

Project => Clean => Set "Clean all projects" => Ok

项目 => 清理 => 设置“清理所有项目” => 好的

P.S. Sorry if I have mistakes - English isn't my native language.

PS对不起,如果我有错误 - 英语不是我的母语。

回答by user4313807

home/user/workspace/appcompat_v7/res/values-v21/themes_base.xml:156: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.

home/user/workspace/appcompat_v7/res/ values-v21/themes_base.xml:156: 错误: 错误: 找不到与给定名称匹配的资源: attr 'android:colorControlNormal'。

I assumed values-v21stands for api level 21, so I updated to android 5.0 and it works for me.

我假设values-v21代表 api 级别 21,所以我更新到 android 5.0,它对我有用。

回答by Sami Gharbi

My solution is more radical: delete all styles files and every reference for them

我的解决方案更激进:删除所有样式文件及其所有引用