带有 Android Studio 2.3 的 Android 支持 Repo 46.0.0 [英] Android Support Repo 46.0.0 with Android Studio 2.3

查看:24
本文介绍了带有 Android Studio 2.3 的 Android 支持 Repo 46.0.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当 Android Studio 通知弹出时,我今天将我的支持存储库更新为 46.0.0.

I updated today my support repository to 46.0.0 as the Android Studio notification popped up.

出现以下错误:

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

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

清单合并失败:属性元数据#android.support.VERSION@value value=(25.3.0) from[com.android.support:support-v13:25.3.0] AndroidManifest.xml:27:9-31也出现在 [com.android.support:preference-v7:26.0.0-alpha1]AndroidManifest.xml:24:9-38 值=(26.0.0-alpha1).建议:添加'tools:replace="android:value"' 到元素AndroidManifest.xml:25:5-27:34 覆盖.

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

我更新了所有依赖项以使用 25.3.0 的修订版 26.0.0 Alpha 1,但结果证明我需要将 compileSdk 从 25 提高到 26.如果你有 AS 2.3,你就不能这样做,你需要从金丝雀获取不稳定的 alpha/beta 版本.

I updated all my dependencies to use Revision 26.0.0 Alpha 1 from 25.3.0, but it turns out I need to bump the compileSdk from 25 to 26. You can't do that if you have AS 2.3, you need to get the unstable alpha/beta version from canary.

此链接显示了更改:https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-0-alpha1

关于迁移到新的 android O,这是链接:https://developer.android.com/preview/migration.html

And concerning migrating to the new android O, that's the link: https://developer.android.com/preview/migration.html

似乎使用 AS 稳定版本不适用于新存储库.

It seems using AS stable version will not work with new repository.

我怎样才能回到 Android Studio Repository Version 45 而不是新的 46?

How can I go back to the Android Studio Repository Version 45 instead of the new 46?

** 更新:合并的清单显示生成的库清单之一包含

** Update: The merged manifest shows one of the generated library manifest contains

<meta-data
        android:name="android.support.VERSION"
        android:value="26.0.0-alpha1" />

但是因为它是一个生成的文件编辑是无用的,这就是为什么现在我会坚持使用 rev 45,直到新的 AS 处于稳定构建中

But since it's a generated file editing is useless, that's why for now I'd stick to rev 45 until the new AS is in stable build

推荐答案

有什么问题

某些库依赖于 Android 支持库的X 或更新"版本,因此 Gradle 依赖项解析会获取最新的可用版本,而忽略您在 dependencies 块中实际指定的精确版本.

What's the problem

Some libraries depend on version "X or newer" of Android support libraries so Gradle dependency resolution grabs whatever is the newest available ignoring you actually have a precise version specified in your dependencies block.

这不是你想要的.您希望所有具有相同版本和主要版本的支持库必须匹配编译 SDK 版本.

This is not what you want. You want all support libraries with same version and major version has to match compile SDK version.

幸运的是,您可以强制使用特定的支持库版本.

Fortunately you can force a specific support library version.

把它放在应用模块的末尾 build.gradle:

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            // Skip multidex because it follows a different versioning pattern.
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.0'
            }
        }
    }
}

当然,用你正在使用的版本替换它.

Of course replace the version with whatever it is you're using.

dependecies 块中支持库的版本值现在无关紧要.

Version values for support libraries in dependecies block are now irrelevant.

这是一个有据可查的方法,并且正在运行.

This is a well documented method and it's working.

查找依赖于一系列支持库版本的库

gradlew dependencies --configuration compile -p <module name> | grep ,

并让上述库的作者知道他们应该传递依赖他们的库可以使用的最古老的支持库.

and let the authors of said libraries know they should transitively depend on the oldest support libs their library can do with.

这旨在完全避免这个问题.

This aims to avoid the issue altogether.

这篇关于带有 Android Studio 2.3 的 Android 支持 Repo 46.0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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