Search code examples
androidreact-nativeexpoeas

expo sdk 52 android build failing


I've upgraded my app to Expo SDK 52 and iOS builds fine, but my Android build is failing because of AndroidManifest.xml merge conflicts. Here is the output from EAS:

[RUN_GRADLEW] FAILURE: Build failed with an exception.
[RUN_GRADLEW] * What went wrong:
[RUN_GRADLEW] Execution failed for task ':app:processReleaseMainManifest'.
[RUN_GRADLEW] > Manifest merger failed : Attribute property#android.adservices.AD_SERVICES_CONFIG@resource value=(@xml/ga_ad_services_config) from [com.google.android.gms:play-services-measurement-api:22.1.2] AndroidManifest.xml:32:13-58
[RUN_GRADLEW]       is also present at [com.facebook.android:facebook-core:18.0.0] AndroidManifest.xml:57:13-55 value=(@xml/ad_services_config).
[RUN_GRADLEW]       Suggestion: add 'tools:replace="android:resource"' to <property> element at AndroidManifest.xml to override.

While debugging, I’ve found that removing one of @react-native-firebase/analytics or react-native-fbsdk-next fixes the problem (likely because there is no longer a manifest merge conflict).

I tried adding a config plugin to add the <property> tag suggested in this error with this code:

const { AndroidConfig, withAndroidManifest } = require('@expo/config-plugins');

function withAndroidManifestMergerRulesFix(config) {
  return withAndroidManifest(config, async (config) => {
    const mainApplication = AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults);
    const resourceName = 'android.adservices.AD_SERVICES_CONFIG';
    const conflictResolvingPropertyTag = {
      $: {
        'android:name': resourceName,
        'android:resource': '@xml/gma_ad_services_config',
        'tools:replace': 'android:resource',
      },
    };
    if (mainApplication['property']) {
      const existingPropertyTags = mainApplication['property'].filter(
        (res) => res.$['android:name'] !== resourceName,
      );
      existingPropertyTags.push(conflictResolvingPropertyTag);
    } else {
      mainApplication['property'] = [conflictResolvingPropertyTag];
    }

    return config;
  });
}

module.exports = withAndroidManifestMergerRulesFix;

Which results in a different error:

[RUN_GRADLEW] FAILURE: Build failed with an exception.
[RUN_GRADLEW] * What went wrong:
[RUN_GRADLEW] Execution failed for task ':app:processReleaseResources'.
[RUN_GRADLEW] > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
[RUN_GRADLEW]    > Android resource linking failed
[RUN_GRADLEW]      ERROR: /private/var/folders/tq/fg72n0nj36g7klqjj4yh67980000gn/T/eas-build-local-nodejs/fdcabbe1-4a0d-4573-a0f6-52b8351035d0/build/android/app/src/main/AndroidManifest.xml:71:5-149: AAPT: error: resource xml/gma_ad_services_config (aka com.growmaple.android:xml/gma_ad_services_config) not found.

I’ve been unable to find an answer to these problems so far. The closest thing related to what I’m seeing says the solution was downgrading com.google.android.gms:play-services-ads from 23.0.0 to 22.3.0 or reverting AGP to 8.2.2. I’m not sure this would be a viable option in an Expo app.

Reference: Android Project problem when implementing admob

I’ve updated my libraries in the app and explored the possibilities I know of. I need both facebook and firebase libraries, so removing one of them is not an option.

Please help!


Solution

  • You need to downgrade your react-native-fbsdk-next to 13.0.0

    Follow this issue to check if it's fixed in future: