添加'tools:replace =" Android:value"'到<元数据> AndroidManifest中的元素 [英] add 'tools:replace="Android:value"' to <meta-data> element at AndroidManifest

查看:178
本文介绍了添加'tools:replace =" Android:value"'到<元数据> AndroidManifest中的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在HeadFirst Android开发中学习了一个教程,并在添加后遇到以下问题:
private ActionBarDrawerToggle drawerToggle;

该控件已过时,因此我按照说明通过添加com.android.support:appcompat-v7:26.0.0-alpha1到应用程序模块来解决该问题依赖关系



但现在我得到以下的构建错误:

错误:执行失败,执行任务':app:processDebugManifest'。
$ b


Manifest合并失败:属性meta-data#android.support.VERSION@value value =(25.3.1)from [com.android.support:recyclerview-v7:25.3.1] AndroidManifest.xml:24:9 -31
也出现在[com.android.support:appcompat-v7:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value =(26.0.0-alpha1)。
建议:在AndroidManifest.xml:22:5-24:34的元素中添加'tools:replace =android:value'以覆盖。

以下是代码:

解决方案

问题是所有支持库的版本和主要版本必须匹配编译SDK版本。

所以试着强制一个特定的支持库版本。
把它放在你的应用程序模块的结尾处 build.gradle

  configurations.all {
resolutionStrategy.eachDependency {DependencyResolveDetails details - >
def requested = details.requested
if(requested.group =='com.android.support'){
if(!requested.name.startsWith(multidex)){
details.useVersion '25 .3.0'
}
}
}
}


I'm following a tutorial in HeadFirst Android development and encountered issues after adding: private ActionBarDrawerToggle drawerToggle;

The control was deprecated so I followed instructions on Stack to resolve that issue by adding com.android.support:appcompat-v7:26.0.0-alpha1 to the app modules Dependencies

But now I'm getting the following build errors:

Error:Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.1) from [com.android.support:recyclerview-v7:25.3.1] AndroidManifest.xml:24:9-31 is also present at [com.android.support:appcompat-v7:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1). Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:22:5-24:34 to override.

Here is the code:

解决方案

Problem is that all support libraries with same version and major version has to match compile SDK version.

So try to force a specific support library version. Put this at the end of your app module in build.gradle.

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.0'
            }
        }
    }
}

这篇关于添加'tools:replace =" Android:value"'到<元数据> AndroidManifest中的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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