I am making a simple alarm app. Wherever I am using Calendar
class it's showing an error same as title.
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 10);
calendar.set(Calendar.MINUTE, 30);
Whenever I build my project, it builds fine but app crashes when it's launched on phone. Below is the Logcat:
07-22 18:24:15.607 18047-18047/com.example.panwa.afinal D/AndroidRuntime: Shutting down VM
07-22 18:24:15.607 18047-18047/com.example.panwa.afinal W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x40d952d0)
07-22 18:24:15.627 18047-18047/com.example.panwa.afinal E/AndroidRuntime: ***FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.icu.util.Calendar***
at com.example.panwa.afinal.MainActivity.startAt10(MainActivity.java:70)
at com.example.panwa.afinal.MainActivity$3.onClick(MainActivity.java:46)
at android.view.View.performClick(View.java:4275)
at android.view.View$PerformClick.run(View.java:17434)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:177)
at android.app.ActivityThread.main(ActivityThread.java:4947)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
07-22 18:25:33.824 18047-18047/com.example.panwa.afinal I/Process: Sending signal. PID: 18047 SIG: 9
I have a set my min SDK to be 11 but still it's not working.
Instead of importing android.icu.util.calendar
, try importing java.util.Calendar
.
The android.icu.util.calendar
is the ICU replacement for java.util.Calendar
but it's only available starting from API 24. So, it will only work on the devices which is API 24 and above.
Ref :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With