loe*_*chg 374 android gradle xamarin.android android-support-library android-5.0-lollipop
尝试在我的项目中使用最新的appcompat-v7支持库时,出现以下错误:
/Users/greg/dev/mobile/android_project/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/res/values-v11/values.xml
Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(36, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
reV*_*rse 597
虽然loeschg的答案是绝对正确的,但我想详细说明并为所有IDE(Eclipse,IntellJ和Android Studio)提供解决方案,即使错误略有不同.
确保您已经下载了最新版本extras
以及Android 5.0 SDK
SDK-Manager.
打开build.gradle
你的应用程序模块的文件,并将你更改compileSdkVersion
为21.基本上没有必要将targetSdkVersion
SDK版本更改为21,但建议你应该始终定位最新的Android Build-Version.
最后你的gradle文件将如下所示:
android {
compileSdkVersion 21
// ...
defaultConfig {
// ...
targetSdkVersion 21
}
}
Run Code Online (Sandbox Code Playgroud)
务必在事后同步您的项目.
当使用v7-appcompat
在Eclipse中,你必须把它作为一个库项目.仅将*.jar复制到您的/libs
文件夹是不够的.请阅读这(点击)一步一步的教程developer.android.com才能知道如何正确导入项目.
导入项目后,您将意识到文件夹中的某些文件/res
夹带有红色下划线,因为出现以下错误:
error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.*'
error: Error: No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Run Code Online (Sandbox Code Playgroud)
您唯一需要做的就是打开project.properties
文件android-support-v7-appcompat
并将目标从更改target=android-19
为target=android-21
.
之后只需执行一次Project --> Clean...
以使更改生效.
与Eclipse类似,只使用android-support-v7-appcompat.jar
; 你必须导入appcompat
作为一个模块.在StackO-Post上阅读更多相关信息(点击).
(注意: 如果你只是使用.jar
你将获得NoClassDefFoundErrors
运行时)
当您尝试构建项目时,您将面临res/values-v**
文件夹中的问题.您的消息窗口将显示如下内容:
Error:android-apt-compiler: [appcompat] resource found that matches the given name: attr 'android:colorPrimary'.
Error:(75, -1) android-apt-compiler: [appcompat] C:\[Your Path]\sdk\extras\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'.
// and so on
Run Code Online (Sandbox Code Playgroud)
右键单击appcompat
模块 - >打开模块设置(F4) - > [依赖选项卡]从下拉列表中选择Android API 21平台 - >应用
然后只需重建项目(Build - > Rebuild Project),你就可以了.
loe*_*chg 123
这很可能是因为您没有compileSdkVersion
在build.gradle文件中将21 设置为21.你也可能想把你改成targetSdkVersion
21.
android {
//...
compileSdkVersion 21
defaultConfig {
targetSdkVersion 21
}
//...
}
Run Code Online (Sandbox Code Playgroud)
这要求您先下载最新的SDK更新.
下载完所有更新后(不要忘记同时更新Android支持库/存储库!)并更新您的compileSdkVersion,重新同步您的Gradle项目.
编辑:适用于Eclipse或一般IntelliJ用户
请参阅reVerse的回答.他有一个非常彻底的步行!
mad*_*527 22
`按照以下步骤:
它为我工作.要解决这个问题,
1.右键单击appcompat_v7库并选择"属性"
2.现在,点击Android选项,将项目构建路径设置为Android 5.0(API级别21)应用更改.
3.现在去appcompat_v7库下的project.properties文件,
4.将项目目标设置为:target = android-21
5.Now Clean +构建appcompat_v7库和你的项目
van*_*dus 12
如果您不想将API 21用作目标API,因此您不想使用Material Theme,则必须使用属于API 19的旧版本>
compile "com.android.support:appcompat-v7:19.0.+"
Run Code Online (Sandbox Code Playgroud)
这也有助于解决您的问题,它只取决于您想要实现的目标.
在Android Studio中,我试图设置compileSdkVersion
和targetSdkVersion
到19
.
我的解决办法是在底部的替换build.gradle
,从这样的:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
Run Code Online (Sandbox Code Playgroud)
到旧版本的appcompat库:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
380746 次 |
最近记录: |