我可以使用针对sdk 21的项目的最新版本的appcompat库吗? [英] Can I use the latest version of the appcompat library with a project that is targeting sdk 21
问题描述
我对这个appcompat库不太了解,所以如果这不是最聪明的问题,我很抱歉。
我有一个项目,我遇到了问题。原来,我将targetSdkVersion设置为23,并且因为我想使用21而导致我遇到了问题。所以我将其更改为21。
在我的build.gradle我编译com.android.support:appcompat-v7:23.1.1。
当我尝试构建时,会导致以下问题:
C:\ Users \Conor\Documents\Programming\AndroidStudioProjects\AndroidStudioProjects\RouteTracker\app\build\intermediates\ exploded-aar\com.android.support\appcompat-v7\23.1.1\res\values-v23\values-v23.xml
错误:(2)检索父项的错误:找不到与给定名称'android:TextAppearance.Material.Widget.Button.Inverse'匹配的资源。
错误: (2)检索父项的错误:找不到与给定名称'android:Widget.Material.Button.Colored'匹配的资源。
错误:任务':app:processDebugResources'的执行失败。
com.android.ide.common.process.ProcessException:org.gradle.process。 internal.ExecException:进程'命令'C:\ Users \Conor\AppData\Local\Android\sdk\build-tools\21.0.0\aapt.exe''以非零结束退出
所以我尝试使用com.android.support:appcompat-v7:21.1.0的appcompat(因为它是唯一的一个我可以明确地找到),但它也没有工作。说它不能找到它,并告诉我使用最新版本,这是23.1.1。
那么我应该使用23.1.1?如果是这样,任何想法这些错误是关于什么?
错误:(2) parent for item:找不到与给定名称'android:TextAppearance.Material.Widget.Button.Inverse'相匹配的资源。
它发生是因为您使用的支持库 v23 需要使用API 23编译
code> build.gradle 这一行:
compileSdkVersion 23
code>
您可以使用其他版本的支持库,但是:
- 注意有另一个使用最新版本的依赖项
- 21.1.0不存在
- 使用正确的api编译
完整列表:
//它需要compileSdkVersion 23
compile'com.android.support:app compat-v7:23.1.1'
compile'com.android.support:appcompat-v7:23.1.0'
compile'com.android.support:appcompat-v7:23.0.1'
编译'com.android.support:appcompat-v7:23.0.0'
//它需要compileSdkVersion 22
编译'com.android.support:appcompat-v7:22.2。 1'
compile'com.android.support:appcompat-v7:22.2.0'
compile'com.android.support:appcompat-v7:22.1.1'
compile'com。 android.support:appcompat-v7:22.1.0'
compile'com.android.support:appcompat-v7:22.0.0'
//它需要compileSdkVersion 21
编译'com.android.support:appcompat-v7:21.0.3'
编译'com.android.support:appcompat-v7:21.0.2'
编译'com.android.support:appcompat- v7:21.0.0'
I dont know much about this appcompat library so apologies if this isnt the smartest question.
I have a project that i was having a problem with. Turns out i had the targetSdkVersion set to 23 and it was causing me a problem since i wanted to use 21. So I changed it to 21.
In my build.gradle I have compile com.android.support:appcompat-v7:23.1.1.
And this causes the following problems when i try to build:
C:\Users\Conor\Documents\Programming\AndroidStudioProjects\AndroidStudioProjects\RouteTracker\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.1\res\values-v23\values-v23.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'. Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Conor\AppData\Local\Android\sdk\build-tools\21.0.0\aapt.exe'' finished with non-zero exit
So I tried to use appcompat of com.android.support:appcompat-v7:21.1.0 (as it was the only one i could definitively find), but it didnt work either. Says it couldnt find it and tells me to use the latest version, which is 23.1.1.
So should I be using 23.1.1? If so, any ideas what these errors are about?
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
It happens because you are using the support libraries v23 which require to compile with API 23.
Change in your build.gradle
this line:
compileSdkVersion 23
You can use another version of the support library but:
- pay attention to have another dependencies which use a latest version
- the 21.1.0 doesn't exist
- use the right api to compile
Here the full list:
//it requires compileSdkVersion 23
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.0'
//it requires compileSdkVersion 22
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:appcompat-v7:22.0.0'
//it requires compileSdkVersion 21
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:appcompat-v7:21.0.0'
这篇关于我可以使用针对sdk 21的项目的最新版本的appcompat库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!