Skip to content

Conversation

XDdevv
Copy link
Contributor

@XDdevv XDdevv commented Aug 25, 2025

🎯 Goal

This PR resolves the deprecation warning for android:allowBackup attribute that appears when targeting Android 12+ (API 31+). The warning indicates that android:allowBackup is deprecated and may be removed in future Android versions, requiring the use of android:dataExtractionRules for proper backup policy configuration.

Warning resolved:

The attribute android:allowBackup is deprecated from Android 12 and higher and may be removed in future versions. Consider adding the attribute android:dataExtractionRules specifying an @xml resource which configures cloud backups and device transfers on Android 12 and higher

🛠 Implementation details

  • Added res/xml/no_backup.xml file defining data extraction rules that disable all backup operations
  • Updated AndroidManifest.xml to include android:dataExtractionRules="@xml/no_backup" attribute
  • Maintained existing backup policy (disabled) while ensuring compatibility with Android 12+ requirements
  • Preserved all existing manifest attributes for backward compatibility

The implementation uses explicit exclusion rules for all backup domains:

  • cloud-backup: Prevents data backup to Google Drive
  • device-transfer: Prevents data transfer during device migration
  • Excludes all domains: root, file, database, sharedpref, external

✍️ Explain examples

File Structure:

app/src/main/res/xml/no_backup.xml (NEW)
app/src/main/AndroidManifest.xml (MODIFIED)

AndroidManifest.xml changes:

<application
    android:name=".PokedexApp"
    android:allowBackup="false"
    android:fullBackupContent="false" <!-- Added this line -->
    android:dataExtractionRules="@xml/no_backup"  <!-- Added this line -->
    android:enableOnBackInvokedCallback="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/Theme.PokedexCompose"
    tools:ignore="AllowBackup">

res/xml/no_backup.xml (new file):

<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
    <cloud-backup>
        <exclude domain="root" />
        <exclude domain="file" />
        <exclude domain="database" />
        <exclude domain="sharedpref" />
        <exclude domain="external" />
    </cloud-backup>
    <device-transfer>
        <exclude domain="root" />
        <exclude domain="file" />
        <exclude domain="database" />
        <exclude domain="sharedpref" />
        <exclude domain="external" />
    </device-transfer>
</data-extraction-rules>

This change:

  • ✅ Eliminates the deprecation warning
  • ✅ Maintains current backup behavior (disabled)
  • ✅ Ensures future Android version compatibility
  • ✅ Follows Android 12+ best practices for backup configuration

XDdevv added 2 commits August 25, 2025 14:10
Add dataExtractionRules to suppress allowBackup deprecation warning
and ensure compatibility with Android 12+ backup policies
@XDdevv XDdevv requested a review from skydoves as a code owner August 25, 2025 09:17
Copy link
Owner

@skydoves skydoves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :)

@skydoves skydoves merged commit ea5308d into skydoves:main Aug 29, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants