Datetimepicker: ANDROID: Task :@react-native-community_datetimepicker:compileDebugJavaWithJavac FAILED

Created on 22 Jul 2019  路  20Comments  路  Source: react-native-datetimepicker/datetimepicker

Bug

Task :@react-native-community_datetimepicker:compileDebugJavaWithJavac FAILED
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:24: error: package androidx.fragment.app does not exist
import androidx.fragment.app.DialogFragment;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:28: error: cannot find symbol
public class RNDatePickerDialogFragment extends DialogFragment {
^
symbol: class DialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:14: error: package androidx.fragment.app does not exist
import androidx.fragment.app.FragmentActivity;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:15: error: package androidx.fragment.app does not exist
import androidx.fragment.app.FragmentManager;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:18: error: package androidx.fragment.app does not exist
import androidx.fragment.app.DialogFragment;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:27: error: cannot find symbol
public class RNTimePickerDialogFragment extends DialogFragment {
^
symbol: class DialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:14: error: package androidx.fragment.app does not exist
import androidx.fragment.app.DialogFragment;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:15: error: package androidx.fragment.app does not exist
import androidx.fragment.app.FragmentActivity;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:16: error: package androidx.fragment.app does not exist
import androidx.fragment.app.FragmentManager;
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:36: error: method does not override or implement a method from a supertype
@Override
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:38: error: cannot find symbol
Bundle args = getArguments();
^
symbol: method getArguments()
location: class RNDatePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:39: error: cannot find symbol
instance = createDialog(args, getActivity(), mOnDateSetListener);
^
symbol: method getActivity()
location: class RNDatePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:122: error: method does not override or implement a method from a supertype
@Override
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogFragment.java:124: error: cannot find symbol
super.onDismiss(dialog);
^
symbol: variable super
location: class RNDatePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:104: error: cannot find symbol
FragmentActivity activity = (FragmentActivity) getCurrentActivity();
^
symbol: class FragmentActivity
location: class RNDatePickerDialogModule
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:104: error: cannot find symbol
FragmentActivity activity = (FragmentActivity) getCurrentActivity();
^
symbol: class FragmentActivity
location: class RNDatePickerDialogModule
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:112: error: cannot find symbol
FragmentManager fragmentManager = activity.getSupportFragmentManager();
^
symbol: class FragmentManager
location: class RNDatePickerDialogModule
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNDatePickerDialogModule.java:129: error: cannot find symbol
fragment.setArguments(createFragmentArguments(options));
^
symbol: method setArguments(Bundle)
location: variable fragment of type RNDatePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:35: error: method does not override or implement a method from a supertype
@Override
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:37: error: cannot find symbol
final Bundle args = getArguments();
^
symbol: method getArguments()
location: class RNTimePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:38: error: cannot find symbol
instance = createDialog(args, getActivity(), mOnTimeSetListener);
^
symbol: method getActivity()
location: class RNTimePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:100: error: method does not override or implement a method from a supertype
@Override
^
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogFragment.java:102: error: cannot find symbol
super.onDismiss(dialog);
^
symbol: variable super
location: class RNTimePickerDialogFragment
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:78: error: cannot find symbol
FragmentActivity activity = (FragmentActivity) getCurrentActivity();
^
symbol: class FragmentActivity
location: class RNTimePickerDialogModule
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:78: error: cannot find symbol
FragmentActivity activity = (FragmentActivity) getCurrentActivity();
^
symbol: class FragmentActivity
location: class RNTimePickerDialogModule
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:87: error: cannot find symbol
FragmentManager fragmentManager = activity.getSupportFragmentManager();
^
symbol: class FragmentManager
location: class RNTimePickerDialogModule
/Users/rahshett/localshiva/QuickCare/node_modules/@react-native-community/datetimepicker/android/src/main/java/com/reactcommunity/rndatetimepicker/RNTimePickerDialogModule.java:104: error: cannot find symbol
fragment.setArguments(createFragmentArguments(options));
^
symbol: method setArguments(Bundle)
location: variable fragment of type RNTimePickerDialogFragment
Note: /Users/rahshett/localshiva/QuickCare/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.
27 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 11s
19 actionable tasks: 11 executed, 8 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.

Environment info

  React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 273.63 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
      npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 26, 27, 28
        Build Tools: 28.0.3
        System Images: android-26 | Intel x86 Atom_64, android-26 | Google APIs Intel x86 Atom, android-27 | Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5692245
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.6 => 16.8.6
      react-native: ^0.59.8 => 0.59.8
    npmGlobalPackages:
      react-native-cli: 2.0.1

Library version: ^1.0.0

Steps To Reproduce

  1. npm i @react-native-community/datetimepicker
  2. npm link @react-native-community/datetimepicker
  3. react-native run-android
    ...

Describe what you expected to happen:

  1. App to install successfully in the Emulator

Most helpful comment

@Swaagie Facing same issue, using v^2.0.0
"react-native": "0.59.5"
"Gradle": 3.4.1

Error: Task: react-native-datetimepicker:compileDebugJavaWithJavac FAILED

All 20 comments

@rashtay thanks for reporting. What version of Gradle did you use to build your app?

In an ideal world the components do not use any deprecated API methods, but I'm not that intimate with the development of the language itself to know first hand what replaces each method.

Most of this code has been directly ported from the code base of React Native itself. Hence I wonder if there is a version discrepancy here. I'll try to reproduce first local. It might just be the 0.60 upgrade, for which there is work in progress, see https://github.com/react-native-community/react-native-datetimepicker/pull/13

@rashtay thanks for reporting. What version of Gradle did you use to build your app?

In an ideal world the components do not use any deprecated API methods, but I'm not that intimate with the development of the language itself to know first hand what replaces each method.

Most of this code has been directly ported from the code base of React Native itself. Hence I wonder if there is a version discrepancy here. I'll try to reproduce the first local. It might just be the 0.60 upgrades, for which there is work in progress, see #13

@Swaagie com.android.tools.build:gradle:3.4.2

I hope this helps. Do let me know if you need clarity on anything else.

@rashtay I've just published @react-native-community/[email protected] which works against React Native 0.60, let me know if that resolves your build issues.

@Swaagie @2.0.0 is not working for me. I'm getting the same issue as above.

Screen Shot 2019-09-06 at 10 20 17 AM

@Swaagie i try to use the ^2.0.0 version but i'm getting same error as @rashtay .

Facing same issue, using v^2.0.0 and "react-native": "0.59.5"

```* What went wrong:
Execution failed for task ':react-native-datetimepicker:compileDebugJavaWithJavac'.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0
```

Do your android detox tests work ?
I tried and it failed. I was wondering how you managed to setup detox skipping build integration and it supposed to work. Looks like not.

> Task :app:compileDebugAndroidTestJavaWithJavac FAILED
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:3: error: package com.wix.detox does not exist
import com.wix.detox.Detox;
                    ^
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:5: error: package org.junit does not exist
import org.junit.Rule;
                ^
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:6: error: package org.junit does not exist
import org.junit.Test;
                ^
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:7: error: package org.junit.runner does not exist
import org.junit.runner.RunWith;
                       ^
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:9: error: package androidx.test.ext.junit.runners does not exist
import androidx.test.ext.junit.runners.AndroidJUnit4;
                                      ^
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:10: error: package androidx.test.filters does not exist
import androidx.test.filters.LargeTest;
                            ^
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:11: error: package androidx.test.rule does not exist
import androidx.test.rule.ActivityTestRule;
                         ^
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:13: error: cannot find symbol
@RunWith(AndroidJUnit4.class)                                                                                                                                                               ^
  symbol: class RunWith
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:14: error: cannot find symbol
@LargeTest
 ^
  symbol: class LargeTest
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:18: error: cannot find symbol
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
           ^
  symbol:   class ActivityTestRule
  location: class DetoxTest
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:17: error: cannot find symbol
    @Rule
     ^
  symbol:   class Rule
  location: class DetoxTest
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:20: error: cannot find symbol
    @Test
     ^
  symbol:   class Test
  location: class DetoxTest
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:18: error: cannot find symbol
    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
                                                              ^
  symbol:   class ActivityTestRule
  location: class DetoxTest
/Users/ksv/Downloads/react-native-datetimepicker-master/example/android/app/src/androidTest/java/com/example/DetoxTest.java:22: error: cannot find symbol
        Detox.runTests(mActivityRule);
        ^
  symbol:   variable Detox
  location: class DetoxTest
14 errors

@Swaagie Facing same issue, using v^2.0.0
"react-native": "0.59.5"
"Gradle": 3.4.1

Error: Task: react-native-datetimepicker:compileDebugJavaWithJavac FAILED

Another broken plugin it seems. Same issue, no chance to compile the app with gradle

Facing same issue. Thought tt works on IOS.

Facing same issue. Is there any solutions for this ?

Same issue. Any work around?

RNDatePickerDialogFragment.java is trying to import from AndroidX:

import androidx.fragment.app.DialogFragment;

So it seems like react-native-datetimepicker does not support react-native < 0.60 ??

@eightyfive jetifier in -r mode should work though, yes?

https://github.com/mikehardy/jetifier#to-reverse-jetify--convert-node_modules-dependencies-to-support-libraries

I had no idea this existed. I'll give it a try. Thanks @mikehardy.

Try to migrate to AndroidX

@mikehardy Thanks for the tip! Got it working by doing:

  1. rm -rf node_modules
  2. npm install
  3. npx jetify -r
  4. npm run android:build

Great to hear that works! Note that I am a huge proponent of moving to AndroidX + react-native 0.60. It is painful. But the auto-linking stuff and cocoapods, they do justify the pain. In the meantime, understanding the pain, I'll keep jetifier working (forwards and backwards) so we can all get work done. Cheers

@mikehardy We will definitely migrate shortly. We developed on expokit, which turned out to be a mistake and will be migrating off of that as well since it prevents us from upgrading to the newest RN version. We're just too close to launch right now to do any major migrations. Thanks again!

closing, please use the solution from https://github.com/react-native-community/react-native-datetimepicker/issues/11#issuecomment-574929166 or upgrade to RN >= 0.60

Was this page helpful?
0 / 5 - 0 ratings