I’m receiving this exception when I try to use DateUtils.addMinutes()
:
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: com.example.apprainha, PID: 7742 java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:304) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.NoClassDefFoundError: org.apache.commons.lang3.-$$Lambda$Validate$XJJZURDO20sZXXyZMfTRRv13t2c at org.apache.commons.lang3.Validate.notNull(Validate.java:225) at org.apache.commons.lang3.time.DateUtils.validateDateNotNull(DateUtils.java:1789) at org.apache.commons.lang3.time.DateUtils.add(DateUtils.java:515) at org.apache.commons.lang3.time.DateUtils.addMinutes(DateUtils.java:472) at com.example.apprainha.threads.ExportaDados.exportCSVs(ExportaDados.java:187) at com.example.apprainha.threads.ExportaDados.doInBackground(ExportaDados.java:60) at com.example.apprainha.threads.ExportaDados.doInBackground(ExportaDados.java:33) at android.os.AsyncTask$2.call(AsyncTask.java:292) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818)
My code is calling DateUtils.addminutes()
to add 1 minute to variable date
like this:
Date target = DateUtils.addminutes(date, 1);
I put the right dependency on my Gradle file:
implementation 'org.apache.commons:commons-lang3:3.11'
I researched a lot about this error and none of the solutions mentioned in another posts solve my problem. How can I fix it?
Advertisement
Answer
Change your grade file to this:
implementation 'org.apache.commons:commons-lang3:3.6'
then you can use this import in your classes:
import org.apache.commons.lang3.StringUtils;