react-native-datetimepicker / datetimepicker

React Native date & time picker component for iOS, Android and Windows
MIT License
2.53k stars 412 forks source link

ANDROID: Task :@react-native-community_datetimepicker:compileDebugJavaWithJavac FAILED #706

Closed 027binitjha closed 1 year ago

027binitjha commented 1 year ago

Bug report

Summary

I am facing build error issue with the latest version or version greater than 6.3.5 of react-native-datetimepicker/datetimepicker.

Reproducible sample code

> Task :react-native-community_datetimepicker: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.7/userguide/command_line_interface.html#sec:command_line_warnings
525 actionable tasks: 525 executed
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/@akayush/react-native-vlc-media-player/android/src/main/java/com/yuanzhou/vlc/vlcplayer/ReactVlcPlayerView.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: /Users/binitchandrajha/Desktop/mobileapp/node_modules/clevertap-react-native/android/src/main/java/com/clevertap/react/CleverTapModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/@gregfrench/react-native-wheel-picker/android/src/main/java/com/zyu/ReactWheelCurvedPickerManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/lottie-react-native/src/android/src/main/java/com/airbnb/android/react/lottie/LottieAnimationViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/lottie-react-native/src/android/src/main/java/com/airbnb/android/react/lottie/LottieAnimationViewManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-async-storage/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: /Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStoragePackage.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/Common.java:76: error: local variable activityContext is accessed from within inner class; needs to be declared final
        int textColorPrimary = getDefaultDialogButtonTextColor(activityContext);
                                                               ^
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:62: error: cannot find symbol
      if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
                                                           ^
  symbol:   method hasActiveReactInstance()
  location: class ReactApplicationContext
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:96: error: cannot find symbol
      if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
                                                           ^
  symbol:   method hasActiveReactInstance()
  location: class ReactApplicationContext
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:106: error: cannot find symbol
      if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
                                                           ^
  symbol:   method hasActiveReactInstance()
  location: class ReactApplicationContext
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:58: error: cannot find symbol
      if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
                                                           ^
  symbol:   method hasActiveReactInstance()
  location: class ReactApplicationContext
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:70: error: cannot find symbol
      if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
                                                           ^
  symbol:   method hasActiveReactInstance()
  location: class ReactApplicationContext
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:80: error: cannot find symbol
      if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
                                                           ^
  symbol:   method hasActiveReactInstance()
  location: class ReactApplicationContext
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
7 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 16s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/@akayush/react-native-vlc-media-player/android/src/main/java/com/yuanzhou/vlc/vlcplayer/ReactVlcPlayerView.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: /Users/binitchandrajha/Desktop/mobileapp/node_modules/clevertap-react-native/android/src/main/java/com/clevertap/react/CleverTapModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/@gregfrench/react-native-wheel-picker/android/src/main/java/com/zyu/ReactWheelCurvedPickerManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/lottie-react-native/src/android/src/main/java/com/airbnb/android/react/lottie/LottieAnimationViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/lottie-react-native/src/android/src/main/java/com/airbnb/android/react/lottie/LottieAnimationViewManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-async-storage/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: /Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStoragePackage.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/binitchandrajha/Desktop/mobileapp/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/Common.java:76: error: local variable activityContext is accessed from within inner class; needs to be declared final
        int textColorPrimary = getDefaultDialogButtonTextColor(activityContext);
                                                               ^
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:62: error: cannot find symbol
      if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
                                                           ^
  symbol:   method hasActiveReactInstance()
  location: class ReactApplicationContext
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:96: error: cannot find symbol
      if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
                                                           ^
  symbol:   method hasActiveReactInstance()
  location: class ReactApplicationContext
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:106: error: cannot find symbol
      if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
                                                           ^
  symbol:   method hasActiveReactInstance()
  location: class ReactApplicationContext
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:58: error: cannot find symbol
      if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
                                                           ^
  symbol:   method hasActiveReactInstance()
  location: class ReactApplicationContext
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:70: error: cannot find symbol
      if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
                                                           ^
  symbol:   method hasActiveReactInstance()
  location: class ReactApplicationContext
/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:80: error: cannot find symbol
      if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
                                                           ^
  symbol:   method hasActiveReactInstance()
  location: class ReactApplicationContext
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
7 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 16s

    at makeError (/Users/binitchandrajha/Desktop/mobileapp/node_modules/execa/index.js:174:9)
    at /Users/binitchandrajha/Desktop/mobileapp/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async runOnAllDevices (/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
    at async Command.handleAction (/Users/binitchandrajha/Desktop/mobileapp/node_modules/@react-native-community/cli/build/index.js:186:9)

Steps to reproduce

  1. … yarn add @react-native-community/datetimepicker
  2. npx react-native run-android

Describe what you expected to happen:

  1. … App to install successfully in the Emulator

Environment info

npx react-native info output:

# paste it here
System:
    OS: macOS 12.5.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 349.30 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 14.19.3 - ~/.nvm/versions/node/v14.19.3/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v14.19.3/bin/yarn
    npm: 8.19.3 - ~/Desktop/mobileapp/node_modules/.bin/npm
    Watchman: 2022.11.14.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9123335
    Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.16.1 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1
    react-native: 0.64.1 => 0.64.1
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

datetimepicker version: 6.7.1

iOS / Android version: x.x

 buildToolsVersion = "29.0.3"
  minSdkVersion = 21
  compileSdkVersion = 31
  targetSdkVersion = 31
  ndkVersion = "20.1.5948944"
  kotlinVersion = '1.5.0'
  androidXCore = "1.8.0"
027binitjha commented 1 year ago

https://github.com/react-native-datetimepicker/datetimepicker/issues/11 solutions given in this issue not worked for me.

VarunBalakrishna commented 1 year ago

I'm having the same issue.

027binitjha commented 1 year ago

@VarunBalakrishna You should try version 6.3.4 it's works in my case. "@react-native-community/datetimepicker":"6.3.4"

Note:- Remove ^ from version numer

"@react-native-community/datetimepicker":"^6.3.4" --->>>>>>>> Don't use like this otherwise it will throw same error.

VarunBalakrishna commented 1 year ago

Thanks mate, that worked!

It seems the issue is that 6.3.5 renamed hasActiveCatalystInstance -> hasActiveReactInstance and that doesn't work on the react native version I'm using (0.63.5) as hasActiveReactInstance was only introduced in 0.65.0.