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

升级Google Places API时出现Manifest合并失败错误求助

Fixing Google Places API Manifest Merge Conflicts When Using Both places and places-compat Dependencies

I’ve run into this exact headache before—when you include both the core places library and places-compat, their manifest entries for AutocompleteActivity clash because they define conflicting theme and windowSoftInputMode values. Here’s how to fix it step by step:

Step 1: Add the Tools Namespace to Your Manifest

First, make sure your root <manifest> tag includes the Android tools namespace (if it doesn’t already). This lets you use the tools:replace attribute to override conflicting library manifest entries:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" <!-- Add this line -->
    package="com.your.app.package">

Step 2: Declare the AutocompleteActivity in Your Manifest

Add the AutocompleteActivity to your own AndroidManifest.xml, explicitly setting the theme and input mode you want, and use tools:replace to tell the build system to prioritize your values over the ones from the libraries:

<activity
    android:name="com.google.android.libraries.places.widget.AutocompleteActivity"
    <!-- Use your app's existing theme, or Google's dedicated Places theme -->
    android:theme="@style/Theme.YourAppName" 
    <!-- Set the input mode that fits your app (adjustResize is a common choice) -->
    android:windowSoftInputMode="adjustResize"
    <!-- Override both conflicting attributes in one line -->
    tools:replace="android:theme,android:windowSoftInputMode" />

Why This Works

Both the places and places-compat libraries include their own declaration of AutocompleteActivity with slightly different theme and windowSoftInputMode settings. By declaring the activity in your manifest and using tools:replace, you’re telling Gradle to ignore the library’s conflicting values and use yours instead.

Quick Troubleshooting Tip

If you still see errors after making these changes:

  • Run Build > Clean Project followed by Build > Rebuild Project to clear cached manifest data.
  • Double-check that your theme is compatible with the Places widget (Material-based themes work best). You can also try Google’s pre-built theme: @style/PlacesTheme.AutoComplete instead of your app’s custom theme.

内容的提问来源于stack exchange,提问作者shahzaib ali

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.06 15:52:43