Skip to content

Expo plugin duplicates tools:replace entries for backup rules and breaks Android manifest merge #672

@manticarodrigo

Description

@manticarodrigo

Hey team,

I ran into an Android build failure after re-running expo prebuild in a React Native / Expo app that uses both react-native-appsflyer and expo-secure-store.

The problem seems to be in the Expo config plugin here:

  • expo/withAppsFlyerAndroid.js

It always appends:

  • android:dataExtractionRules
  • android:fullBackupContent

into tools:replace, even when those keys are already present.

In our app, expo-secure-store is also configuring those same backup attributes, so after expo prebuild the generated AndroidManifest.xml ended up with:

tools:replace=\"android:dataExtractionRules, android:fullBackupContent, android:dataExtractionRules, android:fullBackupContent\"

That causes Android manifest merge to fail with:

Execution failed for task ':app:processDebugMainManifest'.
> Multiple entries with same key: android:dataExtractionRules=REPLACE and android:dataExtractionRules=REPLACE

Environment

  • react-native-appsflyer: 6.17.7
  • Expo SDK: 55
  • expo-secure-store: 55.0.8
  • React Native: 0.83.2

Repro

  1. Create an Expo app that uses react-native-appsflyer and expo-secure-store
  2. Run expo prebuild --platform android
  3. Build Android
  4. Manifest merge fails on :app:processDebugMainManifest

Expected

The plugin should only add each tools:replace key once.

Actual

The plugin concatenates duplicate values into tools:replace, which breaks manifest merge.

What fixed it locally

I patched the plugin to dedupe the values before joining them:

const existingReplace = application['$']['tools:replace'];
const replaceValues = new Set([
  ...(existingReplace?.split(',').map((value) => value.trim()).filter(Boolean) ?? []),
  'android:dataExtractionRules',
  'android:fullBackupContent',
]);
application['$']['tools:replace'] = Array.from(replaceValues).join(', ');

After that, expo prebuild generated:

tools:replace=\"android:dataExtractionRules, android:fullBackupContent\"

and Android built normally again.

Happy to open a PR if that helps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions