henninghall / react-native-date-picker

React Native Date Picker is datetime picker for Android and iOS. It includes date, time and datetime picker modes. The datepicker is customizable and is supporting different languages. It's written with native code to achieve the best possible look, feel and performance.
MIT License
2.25k stars 346 forks source link

Issue with AndroidX compatibility #65

Closed eggybot closed 5 years ago

eggybot commented 5 years ago

Hi, I'm using the latest Android SDK as well the new RN0.59.8 , it seems your package is not compatible with this versions.

I'm getting this errors

> Task :react-native-date-picker:compileReleaseJavaWithJavac FAILED
/Users/jglr/project/app/node_modules/react-native-date-picker/android/src/main/java/com/henninghall/date_picker/DatePickerManager.java:3: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;

thanks,

eggybot commented 5 years ago

I found the solution, closing this one

henninghall commented 5 years ago

@eggybot That's great to hear! Do you mind sharing your solution if anyone else encounters the same thing? 🙂

hopewise commented 5 years ago

@eggybot yea, will you please share it? 👁

henninghall commented 5 years ago

@hopewise it looks like @MuhammadUzair might have a solution here: https://github.com/MuhammadUzair/react-native-date-picker/commit/1dad5464a4d52ef5ddb488637d30e40e01818ee1

Please reply or send a PR if it is working and I will merge it into the library.

MuhammadUzair commented 5 years ago

@henninghall , yes it is working in react-native 0.59.9.Not send PR because I don't test this with react-native older versions.

Current solutions (until not fixed in official library ):

  1. delete yarn.lock and package.lock . (if found in project)
  2. add "react-native-date-picker": "https://github.com/MuhammadUzair/react-native-date-picker" in package.json
henninghall commented 5 years ago

I am trying to track down the issue. I have tried both react native 0.59.9 and 0.59.8 and both are working 😮. So I have not managed to reproduce the issue yet but it seems to be related to grade.

These version declarations (found in app/build.gradle) are the same for both versions that worked:

  ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }

There are some differences in gradle versions:

app/build.gradle: v0.59.8: classpath 'com.android.tools.build:gradle:3.3.1' v0.59.9: classpath("com.android.tools.build:gradle:3.4.0")

gradle/wrapper/gradle-wrapper.properties: v0.59.8: distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip v0.59.9: distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

Working examples v0.59.8 v0.59.9

@MuhammadUzair and @hopewise, could you post your corresponding versions? Or post a link to your project if it is open sourced.

hopewise commented 5 years ago

I have: react-native-date-picke: "https://github.com/MuhammadUzair/react-native-date-picker" react-native: 0.59.9 I tried to apply settings above for react-native: 0.59.9 but I am still have the same issue:

> Task :react-native-date-picker:compileDebugJavaWithJavac FAILED
/Users/samir/Documents/projects/mobile/contractor/mobile-contractors/node_modules/react-native-date-picker/android/src/main/java/com/henninghall/date_picker/DatePickerManager.java:3: error: cannot find symbol
import androidx.annotation.Nullable;
                          ^
  symbol:   class Nullable
  location: package androidx.annotation

I will test the sample v0.59.9 above and check results

hopewise commented 5 years ago

Found the problem! Here is what I did, I run the rn599 sample and it worked fine then I used my package.json file of the problematic project in project rn599, the problem starts to happen when I link the libraries.

After digging, I found that the problem occurs when react-native-push-notification is linked into android project! will you please try to add "react-native-push-notification": "^3.1.2", to your package.json and test .. you will eventually reach the error I got above that seems to be in react-native-date-picker it self /🙄\

henninghall commented 5 years ago

Great found, that makes (kind of) sense. I received a similar error when I tried to link react-native-device-info.

What's confusing me a bit is that @MuhammadUzair seems to have solved it by making changes in this packet 🤔

hopewise commented 5 years ago

I have read this https://github.com/zo0r/react-native-push-notification/issues/1091 and then I applied their solution, but I still have the same issue

That's explain it all: https://developers.google.com/android/guides/releases Warning: This release is a MAJOR version update and breaking change.

MuhammadUzair commented 5 years ago

@henninghall ,I changed some code in root project for AndroidX thats why i need changes in this package.I think others not need that changes.In react-native 0.59.9 (fresh project) working fine with react-native-date-picker. Thanks

hopewise commented 5 years ago

react-native-push-notification causes the issue, what's the recommendation to fix that library while not breaking react-native-date-picker?

henninghall commented 5 years ago

If no one else is able to find a solution that works for everyone, I will try to find one as soon as I can, hopefully within a couple of days.

bilaluplogic commented 5 years ago

I have same issue

node_modules/react-native-date-picker/android/src/main/java/com/henninghall/date_picker/DatePickerManager.java:71: error: cannot find symbol public void setTextColor(PickerView view, @Nullable String color) { ^ symbol: class Nullable location: class DatePickerManager

@henninghall any solution for this?

Juman8 commented 5 years ago

you can try: import android.support.annotation.Nullable ->import androidx.annotation.Nullable;

bilaluplogic commented 5 years ago

you can try: import android.support.annotation.Nullable ->import androidx.annotation.Nullable;

Thanks for your help but I don't know which file need to change?

Juman8 commented 5 years ago

you can try: import android.support.annotation.Nullable ->import androidx.annotation.Nullable;

Thanks for your help but I don't know which file need to change?

in DatePickerManager AndroidX this lib changed: androidx.annotation.Nullable You can check it: https://developer.android.com/jetpack/androidx/migrate

bilaluplogic commented 5 years ago

@Thanhcao86 Changed to android->androidX but still facing same issue

Juman8 commented 5 years ago

really? it worked for me 💃

Juman8 commented 5 years ago

@Thanhcao86 Changed to android->androidX but still facing same issue

Maybe you need add: implementation 'androidx.appcompat:appcompat:1.0.0' I added it instead of the package "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"

bilaluplogic commented 5 years ago

you can try: import android.support.annotation.Nullable ->import androidx.annotation.Nullable;

Thanks for your help but I don't know which file need to change?

This code working correctly.

bilaluplogic commented 5 years ago

@Thanhcao86 Changed to android->androidX but still facing same issue

This is my fault.I only changing android to androidX,forgot to remove support.

raymelon commented 5 years ago

While waiting for the package update, using jetifier worked for me.

https://github.com/kmagiera/react-native-gesture-handler/issues/642#issuecomment-509113481

It causes this error for the RN 0.60. You can solve this by following,

npm i jetifier
npx jetify

fixed it for me on RN 0.60.

Have a good day.

henninghall commented 5 years ago

React Native is now using jetifier by default in the latest release (0.60.3) which will make any version this library compile successfully.

If you of some reason need to stay on RN 0.60.2, 0.60.1, or 0.60.0 you can now install a special AndroidX release of this lib, see Readme -> Installation