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.21k stars 338 forks source link

Android App Crashing when using this package (react native 0.75.2) #858

Closed umeshdangrecha closed 1 week ago

umeshdangrecha commented 3 weeks ago

Describe the bug

Failed to create NativeModule 'RNDatePicker' java.lang.NullPointerException at com.henninghall.date_picker.DatePickerModule.(SourceFile:40) at G5.b.getModule(SourceFile:18) at j2.f.get(SourceFile:13) at com.facebook.react.bridge.ModuleHolder.create(SourceFile:104) at com.facebook.react.bridge.ModuleHolder.getModule(Unknown Source:22) at com.facebook.react.bridge.JavaModuleWrapper.getModule(Unknown Source:2) at com.facebook.react.bridge.JavaModuleWrapper.getConstants(SourceFile:76) at com.facebook.jni.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source:0) at android.os.Looper.loopOnce(Looper.java:257) at android.os.Looper.loop(Looper.java:368) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(SourceFile:52) at java.lang.Thread.run(Thread.java:1012)

Expected behavior App should not crash

To Reproduce react native :- 0.75.2 newArch false


<DatePicker
          theme="light"
            date={new Date()}
          mode='date'
        />

Smartphone (please complete the following information):

dwxw commented 1 week ago

Also discovering this issue since updating react-native to 0.74.5 and gradle 8.7, not sure which is the reason.

dwxw commented 1 week ago

I noticed our proguard rules didn't have the rules mentioned in the readme. There was never a problem so perhaps something changed with the upgrade to gradle 8.7 for us.

Having added the rules in the readme:

-keep public class net.time4j.android.ApplicationStarter
-keep public class net.time4j.PrettyTime

I noticed that Android studio says it can't find the classes, and in the usage.txt proguard was removing ApplicationStarter.

I've changed the rules to

-keep class net.time4j.** { *; }

which keeps everything in net.time4j, and now proguard builds are working again for me. Hope this helps.

umeshdangrecha commented 1 week ago

yes @dwxw, everything is working fine now, Thanks