Android编译出错:app:checkDebugDuplicateClasses

问题
checkDebugDuplicateClasses

Duplicate class android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat found in modules classes.jar (com.android.support:support-compat:28.0.0) and classes.jar (com.android.support:support-v4:23.1.1)

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:app:checkDebugDuplicateClasses’.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:95)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:119)
at org.gradle.api.internal.tasks.execution.ResolvePreviousStateExecuter.execute(ResolvePreviousStateExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:93)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:45)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:94)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:56)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:67)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter 1. c a l l ( E v e n t F i r i n g T a s k E x e c u t e r . j a v a : 49 ) a t o r g . g r a d l e . i n t e r n a l . o p e r a t i o n s . D e f a u l t B u i l d O p e r a t i o n E x e c u t o r 1.call(EventFiringTaskExecuter.java:49) at org.gradle.internal.operations.DefaultBuildOperationExecutor 1.call(EventFiringTaskExecuter.java:49)atorg.gradle.internal.operations.DefaultBuildOperationExecutorCallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:315)
at org.gradle.internal.operations.DefaultBuildOperationExecutor C a l l a b l e B u i l d O p e r a t i o n W o r k e r . e x e c u t e ( D e f a u l t B u i l d O p e r a t i o n E x e c u t o r . j a v a : 305 ) a t o r g . g r a d l e . i n t e r n a l . o p e r a t i o n s . D e f a u l t B u i l d O p e r a t i o n E x e c u t o r . e x e c u t e ( D e f a u l t B u i l d O p e r a t i o n E x e c u t o r . j a v a : 175 ) a t o r g . g r a d l e . i n t e r n a l . o p e r a t i o n s . D e f a u l t B u i l d O p e r a t i o n E x e c u t o r . c a l l ( D e f a u l t B u i l d O p e r a t i o n E x e c u t o r . j a v a : 101 ) a t o r g . g r a d l e . i n t e r n a l . o p e r a t i o n s . D e l e g a t i n g B u i l d O p e r a t i o n E x e c u t o r . c a l l ( D e l e g a t i n g B u i l d O p e r a t i o n E x e c u t o r . j a v a : 36 ) a t o r g . g r a d l e . a p i . i n t e r n a l . t a s k s . e x e c u t i o n . E v e n t F i r i n g T a s k E x e c u t e r . e x e c u t e ( E v e n t F i r i n g T a s k E x e c u t e r . j a v a : 49 ) a t o r g . g r a d l e . e x e c u t i o n . p l a n . L o c a l T a s k N o d e E x e c u t o r . e x e c u t e ( L o c a l T a s k N o d e E x e c u t o r . j a v a : 43 ) a t o r g . g r a d l e . e x e c u t i o n . t a s k g r a p h . D e f a u l t T a s k E x e c u t i o n G r a p h CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:305) at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175) at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:101) at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49) at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:305)atorg.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)atorg.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:101)atorg.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)atorg.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)atorg.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)atorg.gradle.execution.taskgraph.DefaultTaskExecutionGraphInvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph I n v o k e N o d e E x e c u t o r s A c t i o n . e x e c u t e ( D e f a u l t T a s k E x e c u t i o n G r a p h . j a v a : 343 ) a t o r g . g r a d l e . e x e c u t i o n . t a s k g r a p h . D e f a u l t T a s k E x e c u t i o n G r a p h InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343) at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)atorg.gradle.execution.taskgraph.DefaultTaskExecutionGraphBuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph B u i l d O p e r a t i o n A w a r e E x e c u t i o n A c t i o n . e x e c u t e ( D e f a u l t T a s k E x e c u t i o n G r a p h . j a v a : 322 ) a t o r g . g r a d l e . e x e c u t i o n . p l a n . D e f a u l t P l a n E x e c u t o r BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322) at org.gradle.execution.plan.DefaultPlanExecutor BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)atorg.gradle.execution.plan.DefaultPlanExecutorExecutorWorker 1. e x e c u t e ( D e f a u l t P l a n E x e c u t o r . j a v a : 134 ) a t o r g . g r a d l e . e x e c u t i o n . p l a n . D e f a u l t P l a n E x e c u t o r 1.execute(DefaultPlanExecutor.java:134) at org.gradle.execution.plan.DefaultPlanExecutor 1.execute(DefaultPlanExecutor.java:134)atorg.gradle.execution.plan.DefaultPlanExecutorExecutorWorker 1. e x e c u t e ( D e f a u l t P l a n E x e c u t o r . j a v a : 129 ) a t o r g . g r a d l e . e x e c u t i o n . p l a n . D e f a u l t P l a n E x e c u t o r 1.execute(DefaultPlanExecutor.java:129) at org.gradle.execution.plan.DefaultPlanExecutor 1.execute(DefaultPlanExecutor.java:129)atorg.gradle.execution.plan.DefaultPlanExecutorExecutorWorker.execute(DefaultPlanExecutor.java:202)
at org.gradle.execution.plan.DefaultPlanExecutor E x e c u t o r W o r k e r . e x e c u t e N e x t N o d e ( D e f a u l t P l a n E x e c u t o r . j a v a : 193 ) a t o r g . g r a d l e . e x e c u t i o n . p l a n . D e f a u l t P l a n E x e c u t o r ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193) at org.gradle.execution.plan.DefaultPlanExecutor ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)atorg.gradle.execution.plan.DefaultPlanExecutorExecutorWorker.run(DefaultPlanExecutor.java:129)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker
错误源码如下:

checkDebugDuplicateClasses
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:checkDebugDuplicateClasses'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:95)
	at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:91)
	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:119)
	at org.gradle.api.internal.tasks.execution.ResolvePreviousStateExecuter.execute(ResolvePreviousStateExecuter.java:43)
	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:93)
	at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:45)
	at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:94)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:56)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:67)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:315)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:305)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:101)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
	at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
	at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.util.concurrent.ThreadPoolExecutor.runWorker

Android编译出错:app:checkDebugDuplicateClasses_第1张图片
控制台输出结果

Cause 1: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Duplicate class android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat found in modules classes.jar (com.android.support:support-compat:28.0.0) and classes.jar (com.android.support:support-v4:23.1.1)
Duplicate class android.support.v4.app.ActionBarDrawerToggle found in modules classes.jar (com.android.support:support-core-ui:28.0.0) and classes.jar (com.android.support:support-v4:23.1.1)
Duplicate class android.support.v4.app.ActionBarDrawerToggle$Delegate found in modules classes.jar (com.android.support:support-core-ui:28.0.0) and classes.jar (com.android.support:support-v4:23.1.1)
Duplicate class android.support.v4.app.ActionBarDrawerToggle$DelegateProvider found in modules classes.jar (com.android.support:support-core-ui:28.0.0) and classes.jar (com.android.support:support-v4:23.1.1)
Duplicate class android.support.v4.app.ActionBarDrawerToggle$SlideDrawable found in modules classes.jar (com.android.support:support-core-ui:28.0.0) and classes.jar (com.android.support:support-v4:23.1.1)
Duplicate class android.support.v4.app.ActivityCompat found in modules classes.jar (com.android.support:support-compat:28.0.0) and classes.jar (com.android.support:support-v4:23.1.1)
Duplicate class android.support.v4.app.ActivityCompat$1 found in modules classes.jar (com.android.support:support-compat:28.0.0) and classes.jar (com.android.support:support-v4:23.1.1)

解决方法:
在gradle.properties中添加以下内容

android.useAndroidX=true
android.enableJetifier=true

本文参考

更多文章资源,欢迎关注:开发者阵线联盟

Android编译出错:app:checkDebugDuplicateClasses_第2张图片

你可能感兴趣的:(Android编译出错:app:checkDebugDuplicateClasses)