Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AAPT: error: attribute android:enableOnBackInvokedCallback not found. on compileSdkVersion = 31

I am trying to run 3 years old react-native project.

% ./gradlew assembleDebug --stacktrace

> Configure project :react-native-reanimated
Native libs debug enabled: false
Android gradle plugin: 7.0.4
Gradle: 7.5.1
building Reanimated2
...

> Task :app:processDebugResources FAILED

> Task :react-native-navigation:compileReactNative57_5DebugKotlin FAILED
e: /Users/tenna/Desktop/aitem/node_modules/react-native-navigation/lib/android/app/src/reactNative57_5/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt: (12, 1): Class 'ModalContentLayout' is not abstract and does not implement abstract member public abstract fun onChildStartedNativeGesture(p0: View!, p1: MotionEvent!): Unit defined in com.facebook.react.uimanager.RootView

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking failed
     ERROR:/Users/tenna/Desktop/aitem/android/app/build/intermediates/packaged_manifests/debug/AndroidManifest.xml:66: AAPT: error: attribute android:enableOnBackInvokedCallback not found.
...

android:enableOnBackInvokedCallback are present in every AndroidManifest.xml.

gradle.properties:

android.disableAutomaticComponentCreation=true
android.suppressUnsupportedCompileSdk=33
android.useAndroidX=true
android.enableJetifier=true
like image 898
user16525780 Avatar asked May 28 '26 21:05

user16525780


1 Answers

This error is caused with this update: https://developer.android.com/guide/navigation/predictive-back-gesture

In order to build app, follow these steps: Set compile and target sdk versions in android/build.gradle equal to 33:

buildScript {
  ext {
    ...
      compileSdkVersion = 33
      targetSdkVersion = 33
    ...
  }
  ...
}

Then in your android/app/build.gradle add new dependency:

dependencies {
  ...
  implementation "androidx.activity:activity:1.6.0-alpha05"
  ...
}

And in yours AndroidManifest add new property to tag:

<application
  ...
  android:enableOnBackInvokedCallback="true"
>

Finally, do a Gradle Sync and build project.

like image 196
Evok Avatar answered May 31 '26 11:05

Evok



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!