AppsFlyerSDK / appsflyer-react-native-plugin

AppsFlyer plugin for React Native
MIT License
285 stars 202 forks source link

Build fail with new React Native (0.76) and Expo SDK 52 #586

Open fkrein1 opened 3 days ago

fkrein1 commented 3 days ago

Report

Plugin Version

6.15.1

On what Platform are you having the issue?

Android, React Native 0.76 and Expo SDK 52

What did you do?

expo run:android

What did you expect to happen?

Build successful after upgrading from 0.74 to 0.76

What happened instead?

Build failed

Please provide any other relevant information.

Build Error Log Task :app FAILED /Users/fk/peer/code-review/peerbr-mobile/android/app/src/debug/AndroidManifest.xml:19:307-376 Error: Attribute application@dataExtractionRules value=(@xml/secure_store_data_extraction_rules) from AndroidManifest.xml:19:307-376 is also present at [com.appsflyer:af-android-sdk:6.15.1] AndroidManifest.xml:42:9-75 value=(@xml/appsflyer_data_extraction_rules). Suggestion: add 'tools ="android "' to element at AndroidManifest.xml:6:5-162 to override. /Users/fk/peer/code-review/peerbr-mobile/android/app/src/debug/AndroidManifest.xml:19:248-306 Error: Attribute application@fullBackupContent value=(@xml/secure_store_backup_rules) from AndroidManifest.xml:19:248-306 is also present at [com.appsflyer:af-android-sdk:6.15.1] AndroidManifest.xml:43:9-64 value=(@xml/appsflyer_backup_rules). Suggestion: add 'tools ="android "' to element at AndroidManifest.xml:6:5-162 to override. less Copy code
akilamist commented 3 days ago

@fkrein1 any update on this ? having same issue

akilamist commented 3 days ago

just found solution if you are running on Expo follow this steps

create withCustomAndroidManifest inside root of your project

// withCustomAndroidManifest.js
const { withAndroidManifest } = require('@expo/config-plugins');

module.exports = function withCustomAndroidManifest(config) {
  return withAndroidManifest(config, async (config) => {
    const androidManifest = config.modResults;
    const manifest = androidManifest.manifest;

    // Ensure xmlns:tools is present in the <manifest> tag
    if (!manifest.$['xmlns:tools']) {
      manifest.$['xmlns:tools'] = 'http://schemas.android.com/tools';
    }

    const application = manifest.application[0];

    // Add tools:replace attribute for dataExtractionRules and fullBackupContent
    application['$']['tools:replace'] = 'android:dataExtractionRules, android:fullBackupContent';

    // Set dataExtractionRules and fullBackupContent as attributes within <application>
    application['$']['android:dataExtractionRules'] = '@xml/secure_store_data_extraction_rules';
    application['$']['android:fullBackupContent'] = '@xml/secure_store_backup_rules';

    return config;
  });
};

Add the Custom Plugin to app.json: Modify app.json to include the new custom plugin:

{
  "expo": {
    ...
    "plugins": [
      "./withCustomAndroidManifest",
      ...
    ]
  }
}

run prebuild and Manifest.xml will be changed

if you are on bare react native project just add these to Manifest XML

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

fkrein1 commented 3 days ago

@akilamist thanks! It worked here as well. I hope AppsFlyerSDK adds this config change to their plugin in a new release.