You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio添加Google Play服务地图功能时依赖冲突报错求助

解决Android Manifest合并冲突(添加Google Maps时遇到的版本问题)

Hey there, I’ve dealt with this exact manifest merger headache when adding Google Maps to an Android app—let’s get this fixed for you.

先搞懂问题根源

The error you’re seeing:

Error:Execution failed for task ':app:processDebugManifest'. Manifest merger failed : Attribute meta data#android.support.VERSION@value value=(26.0.1) from AndroidManifest.xml:16:13-35 is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0). Suggestion: add 'tools:replace="android:value"' to <meta-da...

This happens because your project has two different versions of the Android Support Library (26.0.1 and 26.1.0) being pulled in—one directly from your app’s dependencies, and another indirectly from the Google Maps library. The manifest merger tool can’t decide which version’s android.support.VERSION meta-data to use, so it throws an error.

两种解决方案,推荐第二种从根源解决

方案1:按照提示用tools:replace强制替换

This is the quick fix suggested in the error message:

  1. First, make sure your root <manifest> tag in AndroidManifest.xml includes the tools namespace:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.your.app.package">
  1. Find the existing <meta-data> tag for android.support.VERSION (or add it if it’s missing) and add the tools:replace attribute:
<meta-data
    android:name="android.support.VERSION"
    android:value="26.1.0"
    tools:replace="android:value" />

This tells the merger tool to use your specified version and ignore conflicting ones from other libraries.

方案2:统一所有Support库版本(更可靠)

The quick fix works, but it’s better to eliminate the version mismatch entirely:

  1. Open your app’s build.gradle file (the one under the app module, not the project-level one)
  2. In the dependencies block, make sure all com.android.support-prefixed dependencies use the same version (26.1.0 in this case). For example, if you have com.android.support:appcompat-v7:26.0.1, update it to 26.1.0.
  3. To prevent indirect dependencies (like the one from Google Maps) from pulling in older versions, add a resolution strategy to force all Support libraries to use your chosen version:
configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:26.1.0'
        force 'com.android.support:appcompat-v7:26.1.0'
        // Add other support libraries you use here (e.g., design, recyclerview)
    }
}

Sync your project with Gradle, and the conflict should be gone.

内容的提问来源于stack exchange,提问作者Leo Connelly

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:11:17