AAPT编译错误:找不到属性android:enableOnBackInvokedCallback。使用compileSdkVersion = 31。

9

我正在尝试运行一个三年前的React Native项目。

% ./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.
...

每个 AndroidManifest.xml 中都有 android:enableOnBackInvokedCallback。

gradle.properties:

android.disableAutomaticComponentCreation=true
android.suppressUnsupportedCompileSdk=33
android.useAndroidX=true
android.enableJetifier=true

3
你弄明白了吗? - Gutyn
1个回答

3
这个错误是由于这个更新引起的:https://developer.android.com/guide/navigation/predictive-back-gesture 为了构建应用,请按照以下步骤进行: 在 android/build.gradle 中设置编译和目标 SDK 版本等于 33:
buildScript {
  ext {
    ...
      compileSdkVersion = 33
      targetSdkVersion = 33
    ...
  }
  ...
}

然后在你的android/app/build.gradle文件中添加新的依赖项:

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

在您的AndroidManifest文件中,向标签添加新属性:

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

最后,进行Gradle同步并构建项目。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接