升级Google Places API时出现Manifest合并失败错误求助
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.AutoCompleteinstead of your app’s custom theme.
内容的提问来源于stack exchange,提问作者shahzaib ali

