当将等级更新为java8

时间:2018-08-13 03:37:07

标签: android android-studio gradle

在将Java版本从1.7升级到1.8之前,一堆测试用例运行良好。但是,在那之后,当我更改任何测试用例并运行项目始终失败时,必须重新构建所有项目。

根据下面的异常,我猜想desugaring类会发生错误,并且desugaring与Java8有关。

有人有好主意吗?

  

org.gradle.api.tasks.TaskExecutionException:任务执行失败   ':app:app:transformClassesWithDesugarForDevelopmentDebugAndroidTest'。在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)     在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)     在   org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)     在   org.gradle.api.internal.tasks.execution.SkipCachedTaskExecuter.execute(SkipCachedTaskExecuter.java:108)     在   org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)     在   org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)     在   org.gradle.api.internal.tasks.execution.ResolveBuildCacheKeyExecuter.execute(ResolveBuildCacheKeyExecuter.java:61)     在   org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)     在   org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)     在   org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)     在   org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)     在   org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)     在   org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)     在   org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)     在   org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)     在   org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker $ 1.run(DefaultTaskGraphExecuter.java:248)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)     在   org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)     在   org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)     在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)     在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.access $ 200(DefaultTaskPlanExecutor.java:79)     在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:104)     在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:98)     在   org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)     在   org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)     在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)     在   org.gradle.internal.concurrent.ExecutorPolicy $ CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)     在   org.gradle.internal.concurrent.ManagedExecutorImpl $ 1.run(ManagedExecutorImpl.java:46)     在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)     在   java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)     在   org.gradle.internal.concurrent.ThreadFactoryImpl $ ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)     在java.lang.Thread.run(Thread.java:745)造成原因:   java.lang.RuntimeException:   com.android.build.api.transform.TransformException:   java.lang.ArrayIndexOutOfBoundsException在   com.android.builder.profile.Recorder $ Block.handleException(Recorder.java:55)     在   com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)     在   com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212)     在sun.reflect.GeneratedMethodAccessor2173.invoke(未知源)在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)在   org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)在   org.gradle.api.internal.project.taskfactory.IncrementalTask​​Action.doExecute(IncrementalTask​​Action.java:46)     在   org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)     在   org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)     在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter $ 1.run(ExecuteActionsTaskExecuter.java:121)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)     在   org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)     在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)     在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)     ... 34更多原因:   com.android.build.api.transform.TransformException:   java.lang.ArrayIndexOutOfBoundsException在   com.android.build.gradle.internal.transforms.DesugarTransform.transform(DesugarTransform.java:292)     在   com.android.build.gradle.internal.pipeline.TransformTask $ 2.call(TransformTask.java:221)     在   com.android.build.gradle.internal.pipeline.TransformTask $ 2.call(TransformTask.java:217)     在   com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)     ... 49更多原因由:java.lang.ArrayIndexOutOfBoundsException   sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)     在   sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)     在   sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)     在java.lang.reflect.Constructor.newInstance(Constructor.java:423)     在   java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:598)     在   java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)     在java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:720)在   com.android.ide.common.internal.WaitableExecutor.waitForTasksWithQuickFail(WaitableExecutor.java:146)     在   com.android.build.gradle.internal.transforms.DesugarIncrementalTransformHelper.getInitalGraphData(DesugarIncrementalTransformHelper.java:162)     在   com.android.build.gradle.internal.transforms.DesugarIncrementalTransformHelper.lambda $ makeDesugaringGraph $ 2(DesugarIncrementalTransformHelper.java:134)     在   com.android.builder.desugaring.DesugaringGraphs.forVariant(DesugaringGraphs.java:50)     在   com.android.build.gradle.internal.transforms.DesugarIncrementalTransformHelper.makeDesugaringGraph(DesugarIncrementalTransformHelper.java:132)     在   com.google.common.base.Suppliers $ NonSerializableMemoizingSupplier.get(Suppliers.java:160)     在   com.android.build.gradle.internal.transforms.DesugarIncrementalTransformHelper.getAdditionalPaths(DesugarIncrementalTransformHelper.java:111)     在   com.android.build.gradle.internal.transforms.DesugarTransform.incrementalAnalysis(DesugarTransform.java:305)     在   com.android.build.gradle.internal.transforms.DesugarTransform.transform(DesugarTransform.java:264)     ... 52更多原因:java.lang.ArrayIndexOutOfBoundsException

1 个答案:

答案 0 :(得分:0)

首先,很抱歉,这个问题没有描述。

在将Java版本从1.7升级到1.8之前,可以编写androidTest代码。之后,当我们更改任何代码并以androidTest项目运行始终失败时,必须重新构建所有项目。

根据上面的异常,猜测去糖化类发生错误,并且去糖化与Java8有关。