Android Manifest合并失败求助:Android 12及以上版本组件需显式指定android:exported属性
Hey there, I’ve run into this exact issue before—let’s break down why this is happening and how to fix it. The error points to com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver missing the android:exported attribute, but since this component comes from the Google Play Services library (not your own code), adding it to your app’s components won’t solve the problem directly. Here are the steps to resolve this:
1. Upgrade Google Play Services Measurement Dependency
Older versions of the Play Services Measurement library don’t include the android:exported attribute required for Android 12+. Make sure you’re using a recent version in your module-level build.gradle:
dependencies { // Use at least version 20.0.0 or newer (latest stable is recommended) implementation 'com.google.android.gms:play-services-measurement:21.5.0' implementation 'com.google.android.gms:play-services-measurement-sdk:21.5.0' }
Upgrading ensures the library’s manifest already includes the correct exported value for the receiver.
2. Explicitly Declare the Receiver in Your App’s Manifest
If upgrading the dependency doesn’t work (or if a third-party library is pulling in an old version), you can explicitly override the receiver’s declaration in your AndroidManifest.xml to add the exported attribute:
<receiver android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver" android:exported="true" tools:node="merge"> <!-- Merges with the library's existing intent filter to avoid conflicts --> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver>
3. Audit Your Dependency Tree for Old Versions
Sometimes third-party libraries (like Branch, Firebase, etc.) can pull in outdated versions of Play Services. Run this Gradle command to check which dependencies are using the old measurement library:
./gradlew app:dependencyInsight --dependency com.google.android.gms:play-services-measurement
Once you identify the culprit, force a unified version by adding a resolution strategy in your module-level build.gradle:
configurations.all { resolutionStrategy { force 'com.google.android.gms:play-services-measurement:21.5.0' force 'com.google.android.gms:play-services-measurement-sdk:21.5.0' } }
4. Clean and Rebuild Your Project
Cache issues can sometimes prevent changes from taking effect. Do the following in Android Studio:
- Go to
Build > Clean Project - Then
Build > Rebuild Project - If that still doesn’t work, try
File > Invalidate Caches... > Invalidate and Restart
After trying these steps, the error should disappear—this fixes the root cause of the missing exported attribute from the library-provided receiver.
内容的提问来源于stack exchange,提问作者User511

