React Native run-android doesn't work - package com.facebook.react.module.annotations does not exist

Viewed 3228

I get the following error when i try to run 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>

My dependencies:

"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"
  },

I tried to remove package-lock.json and node-modules then reinstall, but still receiving same errors. I was working on this exact same project on expo, everything works perfectly. However, when i try to clone the project to a pure react-native project, then this error occurs. Anyone knows how to solve this? Many thanks!

1 Answers

Install @react-native-community/datetimepicker latest version

npm install @react-native-community/datetimepicker --save

then clean gradlew

cd android && gradlew clean

then run the app again

cd.. && react-native run-android
Related