尝试使用 React Native Keychain 时出错

Error when trying to use React Native Keychain

我正在尝试在我的应用程序中使用 React Native Keychain。 我只是安装它 yarn add react-native-keychain 然后 运行 yarn run android 并得到这个错误:

> Task :react-native-keychain:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
83 actionable tasks: 80 executed, 3 up-to-date
Note: /home/david/Desktop/Encarti/encarti-mobile-app-worker/node_modules/@react-native-community/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /home/david/Desktop/Encarti/encarti-mobile-app-worker/node_modules/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
/home/david/Desktop/Encarti/encarti-mobile-app-worker/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/DeviceAvailability.java:30: error: cannot find symbol
    return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE);
                                                                      ^
  symbol:   variable FEATURE_FACE
  location: class PackageManager
/home/david/Desktop/Encarti/encarti-mobile-app-worker/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/DeviceAvailability.java:34: error: cannot find symbol
        return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_IRIS);
                                                                          ^
  symbol:   variable FEATURE_IRIS
  location: class PackageManager
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-keychain:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s

我看到这个 post: Compilation failed (android) after installation of react-native-keychain 并尝试了那里的解决方案,但仍然失败。我该如何解决这个问题?

分享你的代码更有效率:)

https://github.com/oblador/react-native-keychain/issues/351#issuecomment-640788608

试试这个: compileSdkVersion = 29