CircleCI android在UnitTest步骤运行失败

Posted

技术标签:

【中文标题】CircleCI android在UnitTest步骤运行失败【英文标题】:CircleCI android run fail at UnitTest step 【发布时间】:2020-12-08 15:25:21 【问题描述】:

直到昨天早上一切正常,UnitTest step 失败了,即使它在我的本地机器中使用相同的命令 ./gradlew testDevelopDebugUnitTest 传递。

我尝试在CircleCI config的命令中添加--debug选项,日志如下(我删除了一些日志):

10:01:55.996 [DEBUG] [ComponentAttributeMatcher] Selected match org.jdom:jdom2:2.0.6 configuration runtime from candidates [org.jdom:jdom2:2.0.6 configuration runtime] for org.gradle.dependency.bundling=external, org.gradle.jvm.version=11, org.gradle.usage=java-runtime
10:01:55.996 [DEBUG] [ComponentAttributeMatcher] Selected match commons-logging:commons-logging:1.2 configuration runtime from candidates [commons-logging:commons-logging:1.2 configuration runtime] for org.gradle.dependency.bundling=external, org.gradle.jvm.version=11, org.gradle.usage=java-runtime
10:01:55.996 [DEBUG] [ComponentAttributeMatcher] Selected match commons-codec:commons-codec:1.10 configuration runtime from candidates [commons-codec:commons-codec:1.10 configuration runtime] for org.gradle.dependency.bundling=external, org.gradle.jvm.version=11, org.gradle.usage=java-runtime
10:01:55.996 [DEBUG] [ComponentAttributeMatcher] Selected match org.apache.commons:commons-compress:1.12 configuration runtime from candidates [org.apache.commons:commons-compress:1.12 configuration runtime] for org.gradle.dependency.bundling=external, org.gradle.jvm.version=11, org.gradle.usage=java-runtime

//.... many debug logs

10:01:56.611 [ERROR] [BuildExceptionReporter] 
10:01:56.612 [ERROR] [BuildExceptionReporter] FAILURE: Build failed with an exception.
10:01:56.612 [ERROR] [BuildExceptionReporter] 
10:01:56.612 [ERROR] [BuildExceptionReporter] * What went wrong:
10:01:56.612 [ERROR] [BuildExceptionReporter] Execution failed for task ':app:kaptDevelopDebugKotlin'.
10:01:56.612 [ERROR] [BuildExceptionReporter] > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
10:01:56.612 [ERROR] [BuildExceptionReporter]    > java.lang.reflect.InvocationTargetException (no error message)
10:01:56.612 [ERROR] [BuildExceptionReporter] 
10:01:56.612 [ERROR] [BuildExceptionReporter] * Try:
10:01:56.612 [ERROR] [BuildExceptionReporter]  Run with --scan to get full insights.
10:01:56.613 [ERROR] [BuildExceptionReporter] 
10:01:56.613 [ERROR] [BuildExceptionReporter] * Exception is:
10:01:56.613 [ERROR] [BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:kaptDevelopDebugKotlin'.
10:01:56.614 [ERROR] [BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:151)
10:01:56.614 [ERROR] [BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.accept(ExecuteActionsTaskExecuter.java:148)
10:01:56.614 [ERROR] [BuildExceptionReporter]   at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:191)
10:01:56.614 [ERROR] [BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:141)
10:01:56.614 [ERROR] [BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
10:01:56.614 [ERROR] [BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
10:01:56.614 [ERROR] [BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
10:01:56.614 [ERROR] [BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
10:01:56.615 [ERROR] [BuildExceptionReporter]   at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
10:01:56.615 [ERROR] [BuildExceptionReporter]   at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
10:01:56.615 [ERROR] [BuildExceptionReporter]   at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
10:01:56.615 [ERROR] [BuildExceptionReporter] Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
10:01:56.615 [ERROR] [BuildExceptionReporter]   at org.gradle.workers.internal.DefaultWorkerExecutor$WorkerExecution.waitForCompletion(DefaultWorkerExecutor.java:285)
10:01:56.615 [ERROR] [BuildExceptionReporter]   at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:115)
10:01:56.615 [ERROR] [BuildExceptionReporter]   at org.gradle.internal.work.DefaultAsyncWorkTracker.access$000(DefaultAsyncWorkTracker.java:34)
10:01:56.615 [ERROR] [BuildExceptionReporter]   at org.gradle.internal.work.DefaultAsyncWorkTracker$2.run(DefaultAsyncWorkTracker.java:83)
10:01:56.615 [ERROR] [BuildExceptionReporter]   at org.gradle.internal.Factories$1.create(Factories.java:25)
10:01:56.615 [ERROR] [BuildExceptionReporter]   at org.gradle.internal.work.DefaultWorkerLeaseService.withoutLocks(DefaultWorkerLeaseService.java:254)
10:01:56.617 [ERROR] [BuildExceptionReporter]   at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:120)
10:01:56.617 [ERROR] [BuildExceptionReporter]   ... 35 more
10:01:56.617 [ERROR] [BuildExceptionReporter] Caused by: java.lang.reflect.InvocationTargetException
10:01:56.617 [ERROR] [BuildExceptionReporter]   at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:01:56.617 [ERROR] [BuildExceptionReporter]   at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
10:01:56.617 [ERROR] [BuildExceptionReporter]   at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
10:01:56.617 [ERROR] [BuildExceptionReporter]   at org.jetbrains.kotlin.gradle.internal.KaptExecution.run(KaptWithoutKotlincTask.kt:158)
10:01:56.617 [ERROR] [BuildExceptionReporter]   at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:215)
10:01:56.618 [ERROR] [BuildExceptionReporter]   at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:164)
10:01:56.618 [ERROR] [BuildExceptionReporter]   at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:131)
10:01:56.618 [ERROR] [BuildExceptionReporter]   ... 3 more
10:01:56.618 [ERROR] [BuildExceptionReporter] Caused by: java.util.ServiceConfigurationError: javax.annotation.processing.Processor: android.databinding.annotationprocessor.ProcessDataBinding Unable to get public no-arg constructor
10:01:56.618 [ERROR] [BuildExceptionReporter]   at kotlin.collections.CollectionsKt___CollectionsKt.toCollection(_Collections.kt:1200)
10:01:56.618 [ERROR] [BuildExceptionReporter]   at kotlin.collections.CollectionsKt___CollectionsKt.toMutableList(_Collections.kt:1233)
10:01:56.618 [ERROR] [BuildExceptionReporter]   at kotlin.collections.CollectionsKt___CollectionsKt.toList(_Collections.kt:1224)
10:01:56.618 [ERROR] [BuildExceptionReporter]   at org.jetbrains.kotlin.kapt3.base.ProcessorLoader.doLoadProcessors(ProcessorLoader.kt:80)
10:01:56.618 [ERROR] [BuildExceptionReporter]   at org.jetbrains.kotlin.kapt3.base.ProcessorLoader.loadProcessors(ProcessorLoader.kt:45)
10:01:56.618 [ERROR] [BuildExceptionReporter]   at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:42)
10:01:56.618 [ERROR] [BuildExceptionReporter]   ... 25 more
10:01:56.618 [ERROR] [BuildExceptionReporter] Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
10:01:56.618 [ERROR] [BuildExceptionReporter]   ... 31 more
10:01:56.618 [ERROR] [BuildExceptionReporter] Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
10:01:56.618 [ERROR] [BuildExceptionReporter]   ... 31 more
10:01:56.618 [ERROR] [BuildExceptionReporter] 
10:01:56.618 [ERROR] [BuildExceptionReporter] 
10:01:56.618 [ERROR] [BuildExceptionReporter] * Get more help at https://help.gradle.org

我现在遇到了这个问题,我猜jvm version: org.gradle.jvm.version=11 不正确(您可以在调试日志中看到)。我的本地机器运行与

Matching Java Virtual Machines (1): 1.8.0_222, x86_64

我说的对吗?因为在 CircleCI 文档中The CircleCI Android image is based on the openjdk:8-jdk official Docker image

如何设置CircleCI与我的本地机器运行相同的版本?

【问题讨论】:

【参考方案1】:

Android 映像已移至 Java v11。

请在 CircleCi 讨论中查看this thread。

【讨论】:

感谢您的信息。这是主要原因。

以上是关于CircleCI android在UnitTest步骤运行失败的主要内容,如果未能解决你的问题,请参考以下文章

如何在CircleCI 2.0上配置顺序工作流?

在 CircleCI 2.0 中使用 `yarn`

如何在 circleci 作业中执行“docker run”命令

CircleCI 没有运行“npm run”命令

用于公共存储库的 CircleCI 2.0 私有环境密钥

测试在 Xcode 中通过,但在 Circleci 上失败