Gradle 在为“targetApi"合并清单时失败; [英] Gradle fails on manifest merging for "targetApi"
问题描述
我的项目在清单中包含使用 tools:targetApi
属性忽略一些警告的活动声明.具体:
My project contains activity declarations in the manifest that use the tools:targetApi
attribute to ignore some warnings. Specifically:
<activity
android:name=".activities.ProtocolActivity"
android:label="@string/title_activity_protocols"
android:parentActivityName=".activities.InformationActivity"
tools:targetApi="jelly_bean">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.InformationActivity" />
</activity>
然而,突然之间,例如在切换分支后,我收到以下编译错误:
Out of the blue, however, for instance after switching branches, I get the following compilation error:
错误:/home/paul/git/ally-v2-app/app/src/main/AndroidManifest.xml:67:9-80:20:错误:无效指令targetApi",有效指令为:删除,替换,严格
...
错误:java.lang.IllegalArgumentException:否枚举常量 com.android.manifmerger.AttributeOperationType.TARGETAPI
Error:/home/paul/git/ally-v2-app/app/src/main/AndroidManifest.xml:67:9-80:20: Error: Invalid instruction 'targetApi', valid instructions are : REMOVE,REPLACE,STRICT
...
Error:java.lang.IllegalArgumentException: No enum constant com.android.manifmerger.AttributeOperationType.TARGETAPI
我正在使用以下内容:
- Gradle 2.10
- Gradle 插件 2.0.0-beta6
- Android Studio 2.0 测试版 6
- 在 Ubuntu 15.10 机器和 Windows 10 机器上
似乎我可以通过清除缓存并重新启动 Android Studio 或删除属性、构建然后再次添加它们来使事情再次运行.
It seems I can get things working again by clearing the cache and restarting Android Studio, or removing the attributes, building, then adding them again.
推荐答案
替换为
tools:ignore="UnusedAttribute"
还修复 lint 问题.
这篇关于Gradle 在为“targetApi"合并清单时失败;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!