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

Google Places升级至2.0.0遇Manifest合并失败,求解决方案

Fixing Manifest Merger Failure When Upgrading Google Places SDK to 2.0.0

Hey there, I’ve dealt with similar SDK upgrade headaches before—let’s get this sorted out step by step.

Background

You were running into issues with version 1.1.0 of the Google Places SDK: when users typed more than 3 characters, the autocomplete results would disappear or behave erratically. Even though the project built fine with 1.1.0, switching to implementation 'com.google.android.libraries.places:places:2.0.0' threw a Manifest merger failed with multiple errors, see logs error, and your project won’t build.

Why This Happens

The 2.0.0 version of the Places SDK made significant changes to its manifest declarations—things like required permissions, embedded components, and minimum SDK requirements. Chances are your project’s existing manifest or other dependencies are conflicting with these new declarations.

Step-by-Step Solutions

1. First, Get the Exact Conflict Details

The error message mentions "see logs," but the stack trace you shared only shows the Gradle execution failure. To fix this, you need the specific manifest merge errors:

  • In Android Studio, go to View > Tool Windows > Build and look for sections labeled Merging Errors—this will tell you exactly what’s conflicting (duplicate activities, mismatched SDK versions, etc.).
  • Alternatively, run this command in your terminal to get a detailed log:
    ./gradlew app:processDebugManifest --info
    
    (Windows users use gradlew.bat instead.) Scan the output for lines starting with error: to pinpoint the issue.

2. Resolve Common Conflict Scenarios

Scenario A: Minimum SDK Version Mismatch

Places SDK 2.0.0 requires a minimum SDK version of API 16. If your project’s minSdkVersion is lower than that, the manifest will fail to merge. Check your module-level build.gradle file:

android {
    defaultConfig {
        minSdkVersion 16 // Update this to at least 16 if it's lower
        // ... other configs
    }
}

Scenario B: Duplicate Components or Permissions

The 2.0.0 SDK automatically adds components like AutocompleteActivity to your manifest. If you manually declared any Places-related components or permissions in your own AndroidManifest.xml, this causes a conflict.

  • First, remove any manual declarations of Places components (like AutocompleteActivity) from your manifest—let the SDK handle this.
  • If the conflict is with a duplicate permission, use the tools:node attribute to resolve it. For example, if there’s a duplicate location permission:
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
        tools:node="replace" />
    
    Note: You’ll need to add the tools namespace to your manifest root tag if you haven’t already:
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools">
    

Scenario C: Google Play Services Version Conflict

Places SDK 2.0.0 depends on a specific version of Google Play Services. If other dependencies in your project use a different version, this can cause manifest conflicts. To fix this, standardize the Play Services version in your project-level build.gradle:

ext {
    googlePlayServicesVersion = "17.0.0" // Match the version required by Places 2.0.0
}

Then use this variable for all Play Services dependencies:

implementation "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
implementation "com.google.android.libraries.places:places:2.0.0"

3. Clean and Rebuild Your Project

After making these changes, do a full clean to clear any cached build files:

  • In Android Studio: Build > Clean Project, then Build > Rebuild Project
  • Or via terminal:
    ./gradlew clean build
    

Quick Heads-Up Post-Upgrade

Once you get the project building, remember that Places SDK 2.0.0 changed the initialization process. You’ll need to call Places.initialize(context, YOUR_API_KEY) before using any autocomplete features—this wasn’t required in 1.1.0. Also, double-check that your Google Cloud API key has the Places API enabled and proper restrictions set.


内容的提问来源于stack exchange,提问作者Orlov Const

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 07:49:24