【发布时间】:2020-04-03 10:11:36
【问题描述】:
当我尝试运行 react-native run-android 时出现以下错误:
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
D:\Work\CS\CSMobile\node_modules\@react-native-community\datetimepicker\android\src\main\java\com\reactcommunity\rndatetimepicker\RNDatePickerDialogModule.java:20: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
^
D:\Work\CS\CSMobile\node_modules\@react-native-community\datetimepicker\android\src\main\java\com\reactcommunity\rndatetimepicker\RNDatePickerDialogModule.java:29: error: cannot find symbol
@ReactModule(name = RNDatePickerDialogModule.FRAGMENT_TAG)
^
symbol: class ReactModule
D:\Work\CS\CSMobile\node_modules\@react-native-community\datetimepicker\android\src\main\java\com\reactcommunity\rndatetimepicker\RNTimePickerDialogModule.java:21: error: package com.facebook.react.module.annotations does not exist
import com.facebook.react.module.annotations.ReactModule;
^
D:\Work\CS\CSMobile\node_modules\@react-native-community\datetimepicker\android\src\main\java\com\reactcommunity\rndatetimepicker\RNTimePickerDialogModule.java:29: error: cannot find symbol
@ReactModule(name = RNTimePickerDialogModule.FRAGMENT_TAG)
^
symbol: class ReactModule
D:\Work\CS\CSMobile\node_modules\@react-native-community\datetimepicker\android\src\main\java\com\reactcommunity\rndatetimepicker\RNDateTimePickerPackage.java:12: error: RNDateTimePickerPackage is not abstract and does not override abstract method createJSModules() in ReactPackage
public class RNDateTimePickerPackage implements ReactPackage {
^
Note: D:\Work\CS\CSMobile\node_modules\@react-native-community\datetimepicker\android\src\main\java\com\reactcommunity\rndatetimepicker\RNDatePickerDialogFragment.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-community_datetimepicker: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 3s
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (D:\Work\CS\CSMobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at buildAndRun (D:\Work\CS\CSMobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:179:41)
at D:\Work\CS\CSMobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:133:12
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Command.handleAction (D:\Work\CS\CSMobile\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:182:9)
PS D:\Work\CS\CSMobile>
我的依赖:
"dependencies": {
"@eva-design/eva": "^1.2.0",
"@react-native-community/datetimepicker": "2.1.0",
"@types/html-entities": "^1.2.16",
"@types/object-hash": "^1.3.1",
"@types/react-native-material-textfield": "^0.16.3",
"@types/uuid": "^3.4.7",
"axios": "^0.19.2",
"date-fns": "^2.10.0",
"html-entities": "^1.2.1",
"object-hash": "^2.0.2",
"react": "16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz",
"react-native-elements": "^1.2.7",
"react-native-flash-message": "^0.1.15",
"react-native-gesture-handler": "~1.5.0",
"react-native-keyboard-aware-scroll-view": "^0.8.0",
"react-native-modal-datetime-picker": "^8.5.1",
"react-native-reanimated": "~1.4.0",
"react-native-router-flux": "^4.2.0",
"react-native-screens": "2.0.0-alpha.12",
"react-native-svg": "9.13.3",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^1.9.4",
"react-navigation-tabs": "^2.5.6",
"react-redux": "^7.1.3",
"recompose": "^0.30.0",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"uuid": "^3.4.0"
},
我尝试删除 package-lock.json 和 node-modules 然后重新安装,但仍然收到相同的错误。 我在世博会上做这个完全相同的项目,一切都很完美。但是,当我尝试将项目克隆为纯 react-native 项目时,就会发生此错误。 任何人都知道如何解决这个问题?非常感谢!
【问题讨论】:
标签: react-native