Compilation failed (android) after installation of react-native-keychain

浪子不回头ぞ 提交于 2020-08-06 06:18:18

问题


This is a new installation on a RN 0.62.2 and Nodejs 12.18.0. After yarn add react-native-keychain, the app launch of npx react-native run-android failed with the error:

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\D\code\js\xyz_app\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
C:\D\code\js\xyz_app\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.

Tried a few times with installation and the error is the same. The modules has been used in other app before and the error may be related to the recent update of the module. The OS is win10. react-native-keychain is 6.1.1. Here is the package.json:

"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/native": "^5.5.1",
"@react-navigation/stack": "^5.5.1",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-device-info": "^5.6.1",
"react-native-elements": "^2.0.2",
"react-native-gesture-handler": "^1.6.1",
"react-native-keychain": "^6.1.1",
"react-native-reanimated": "^1.9.0",
"react-native-safe-area-context": "^3.0.5",
"react-native-screens": "^2.8.0",
"react-native-vector-icons": "^6.6.0"

回答1:


Bumped up the SDK version from 28 t0 29 in build.gradle seems working. Here is the file after change:

        buildToolsVersion = "29.0.3"
        minSdkVersion = 16
        compileSdkVersion = 29
        targetSdkVersion = 29


来源:https://stackoverflow.com/questions/62398553/compilation-failed-android-after-installation-of-react-native-keychain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!