当我尝试使用时收到此异常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)
我的代码正在调用DateUtils.addminutes()
向变量添加 1 分钟,date
如下所示:
Date target = DateUtils.addminutes(date, 1);
我对我的 Gradle 文件进行了正确的依赖:
implementation 'org.apache.commons:commons-lang3:3.11'
我对此错误进行了很多研究,但其他帖子中提到的解决方案都没有解决我的问题。我该如何解决?