Skip to content

Conversation

@XDdevv
Copy link
Contributor

@XDdevv XDdevv commented Aug 25, 2025

🎯 Goal

This PR resolves the lint warning for android:enableOnBackInvokedCallback attribute that appears when the minimum SDK version is below API 33. The warning indicates that this attribute is only used in API level 33+ while the current minimum is API 21.

Warning resolved:

Attribute enableOnBackInvokedCallback is only used in API level 33 and higher (current min is 21)

The enableOnBackInvokedCallback attribute enables Android 13's Predictive Back Gesture feature, which provides smooth back navigation animations and previews. This attribute is safely ignored on older Android versions without causing crashes or issues.

🛠 Implementation details

  • Added tools:targetApi="33" attribute to suppress the lint warning
  • Maintained existing functionality and compatibility with all supported Android versions (API 21+)
  • Preserved predictive back gesture support for Android 13+ devices
  • No breaking changes - attribute is ignored on devices below API 33

The tools:targetApi="33" annotation explicitly tells the Android lint system that the usage of this API 33+ attribute is intentional and should not trigger warnings.

✍️ Explain examples

AndroidManifest.xml changes:

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

Behavior by Android version:

  • Android 13+ (API 33+): Predictive back gesture enabled with smooth animations
  • Android 12 and below (API 21-32): Attribute ignored, standard back behavior maintained
  • No crashes or compatibility issues on any supported version

This change:

  • ✅ Eliminates the lint warning
  • ✅ Maintains backward compatibility with older Android versions
  • ✅ Enables modern back gesture experience on supported devices
  • ✅ Follows Android development best practices for forward compatibility

- Add tools:targetApi="33" to suppress lint warning for enableOnBackInvokedCallback
- Attribute is safely ignored on devices below API 33
- Ensures predictive back gesture support on Android 13+ devices
@XDdevv XDdevv requested a review from skydoves as a code owner August 25, 2025 09:22
@skydoves skydoves merged commit 15c6f1a 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