Gradle在清单合并"targetApi"时失败. [英] Gradle fails on manifest merging for "targetApi"

查看:304
本文介绍了Gradle在清单合并"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

我正在使用以下内容:

  • 2.10级
  • Gradle插件2.0.0-beta6
  • Android Studio 2.0 beta 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"

修复皮棉问题.

这篇关于Gradle在清单合并"targetApi"时失败.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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