@@ -30,18 +30,23 @@ function withCustomAndroidManifest(config) {
3030 const application = manifest . application [ 0 ] ;
3131
3232 // Add tools:replace attribute for dataExtractionRules and fullBackupContent
33+ // This allows AppsFlyer SDK's built-in backup rules to take precedence over
34+ // conflicting rules in the app's manifest (see: https://dev.appsflyer.com/hc/docs/install-android-sdk#backup-rules)
3335 const existingReplace = application [ '$' ] [ 'tools:replace' ] ;
3436 if ( existingReplace ) {
35- const newReplace = existingReplace + ', android:dataExtractionRules, android:fullBackupContent' ;
36- application [ '$' ] [ 'tools:replace' ] = newReplace ;
37+ // Add to existing tools:replace if not already present
38+ const replaceAttrs = existingReplace . split ( ',' ) . map ( s => s . trim ( ) ) ;
39+ if ( ! replaceAttrs . includes ( 'android:dataExtractionRules' ) ) {
40+ replaceAttrs . push ( 'android:dataExtractionRules' ) ;
41+ }
42+ if ( ! replaceAttrs . includes ( 'android:fullBackupContent' ) ) {
43+ replaceAttrs . push ( 'android:fullBackupContent' ) ;
44+ }
45+ application [ '$' ] [ 'tools:replace' ] = replaceAttrs . join ( ', ' ) ;
3746 } else {
3847 application [ '$' ] [ 'tools:replace' ] = 'android:dataExtractionRules, android:fullBackupContent' ;
3948 }
4049
41- // Set dataExtractionRules and fullBackupContent as attributes within <application>
42- application [ '$' ] [ 'android:dataExtractionRules' ] = '@xml/secure_store_data_extraction_rules' ;
43- application [ '$' ] [ 'android:fullBackupContent' ] = '@xml/secure_store_backup_rules' ;
44-
4550 console . log ( '[AppsFlyerPlugin] Android manifest modifications completed' ) ;
4651
4752 return config ;
@@ -52,7 +57,8 @@ module.exports = function withAppsFlyerAndroid(config, { shouldUsePurchaseConnec
5257 if ( shouldUsePurchaseConnector ) {
5358 config = addPurchaseConnectorFlag ( config ) ;
5459 }
55- // Always apply Android manifest modifications for secure data handling
60+ // Apply Android manifest modifications to resolve backup rules conflicts with AppsFlyer SDK
61+ // This ensures AppsFlyer SDK's built-in backup rules take precedence (see issue #631)
5662 config = withCustomAndroidManifest ( config ) ;
5763
5864 return config ;
0 commit comments