添加 'tools:replace="Android:value"'<元数据>AndroidManifest 中的元素 [英] add &#39;tools:replace=&quot;Android:value&quot;&#39; to &lt;meta-data&gt; element at AndroidManifest

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

问题描述

我正在学习 HeadFirst Android 开发中的教程,并在添加后遇到问题:private ActionBarDrawerToggle drawerToggle;

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

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

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:

错误:任务:app:processDebugManifest"的执行失败.

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

清单合并失败:属性 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"'来覆盖.

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.

代码如下:

推荐答案

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

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

所以尝试强制使用特定的支持库版本.将其放在 build.gradle 中应用模块的末尾.

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天全站免登陆