尝试使用React Native钥匙串时出错

时间:2020-07-15 21:05:08

标签: react-native react-native-keychain

我正在尝试在我的应用中使用React Native钥匙串。 我只安装了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

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

1 个答案:

答案 0 :(得分:0)

共享您的代码效率更高:)

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

尝试一下: compileSdkVersion = 29