动态功能发布版本因资源重复而失败

时间:2019-04-18 07:09:53

标签: android android-resources dynamic-feature

我正在创建一个示例来检查android提供的动态功能交付。我有以下方式的项目结构。基础项目 app 和一项动态功能 sample_dynamic_feature 。动态功能交付所需的所有设置均已就绪。当我在基本模块以及动态模块中添加任何具有相同名称的布局文件或.xml文件时,就会出现问题。我在基本应用程序和动态模块中都添加了 activity_main.xml 。我收到以下错误:

出了什么问题:

Execution failed for task ':app:packageReleaseBundle'.
> java.util.concurrent.ExecutionException: com.android.tools.build.bundletool.exceptions.ValidationException: com.android.tools.build.bundletool.exceptions.ValidationException: Modules 'base' and 'sample_dynamic_feature' contain entry 'res/layout/activity_main.xml' with different content.

可以和:

一起使用
Above setup works fine in debug mode.
./gradlew assembleDebug
./gradlew assembleRelease

失败原因:

In case of release mode it gives me above error.
./gradlew bundleDebug
./gradlew bundleRelease

完整的堆栈跟踪:

  

例外是:           org.gradle.api.tasks.TaskExecutionException:任务':app:packageReleaseBundle'的执行失败。                   在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110)                   在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)                   在org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)处                   在org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)                   在org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)                   在org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)                   在org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)处                   在org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)                   在org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)                   在org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)处                   在org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)                   在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.api.internal.tasks.execution.EventFiringTaskExecuter $ 1.run(EventFiringTaskExecuter.java:51)                   在org.gradle.internal.operations.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)处                   在org.gradle.internal.operations.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)处                   在org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)                   在org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)                   在org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)                   在org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)                   在org.gradle.execution.taskgraph.LocalTask​​InfoExecutor.execute(LocalTask​​InfoExecutor.java:42)                   在org.gradle.execution.taskgraph.DefaultTaskExecutionGraph $ BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)处                   在org.gradle.execution.taskgraph.DefaultTaskExecutionGraph $ BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)处                   在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ ExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:135)处                   在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ ExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:130)处                   在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)处                   在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)处                   在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)处                   在org.gradle.internal.concurrent.ExecutorPolicy $ CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)                   在org.gradle.internal.concurrent.ManagedExecutorImpl $ 1.run(ManagedExecutorImpl.java:46)                   在org.gradle.internal.concurrent.ThreadFactoryImpl $ ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)           引起原因:org.gradle.internal.UncheckedException:java.util.concurrent.ExecutionException:com.android.tools.build.bundletool.exceptions.ValidationException:模块“ base”和“ sample_dynamic_feature”包含条目“ res / layout / activity_main”。 xml”具有不同的内容。                   在org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:63)                   在org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40)                   在org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:76)                   在org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.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.AbstractTask $ TaskActionWrapper.execute(AbstractTask.java:801)                   在org.gradle.api.internal.AbstractTask $ TaskActionWrapper.execute(AbstractTask.java:768)                   在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter $ 1.run(ExecuteActionsTaskExecuter.java:131)                   在org.gradle.internal.operations.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)处                   在org.gradle.internal.operations.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)处                   在org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)                   在org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)                   在org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)                   在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)处                   在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)                   ...另外31个           原因:java.util.concurrent.ExecutionException:com.android.tools.build.bundletool.exceptions.ValidationException:模块“ base”和“ sample_dynamic_feature”包含条目“ res / layout / activity_main.xml”,其内容不同。                   在com.android.ide.common.workers.ExecutorServiceAdapter.close(ExecutorServiceAdapter.kt:56)                   在kotlin.io.CloseableKt.closeFinally(Closeable.kt:53)                   在com.android.build.gradle.internal.tasks.PackageBundleTask.bundleModules(PackageBundleTask.kt:121)                   在org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)                   ...另外44个           引起原因:com.android.tools.build.bundletool.exceptions.ValidationException:模块“ base”和“ sample_dynamic_feature”包含具有不同内容的条目“ res / layout / activity_main.xml”。                   在com.android.tools.build.bundletool.exceptions.ValidationException $ Builder.build(ValidationException.java:49)                   在com.android.tools.build.bundletool.exceptions.ValidationException $ Builder.build(ValidationException.java:41)                   在com.android.tools.build.bundletool.validation.EntryClashValidator.checkEqualEntries(EntryClashValidator.java:66)                   在com.android.tools.build.bundletool.validation.EntryClashValidator.validateAllModules(EntryClashValidator.java:52)                   在com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleModulesUsingSubValidator(ValidatorRunner.java:75)处                   在com.android.tools.build.bundletool.validation.ValidatorRunner.lambda $ validateBundleModules $ 4(ValidatorRunner.java:64)                   在com.google.common.collect.ImmutableList.forEach(ImmutableList.java:407)                   在com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleModules(ValidatorRunner.java:63)                   在com.android.tools.build.bundletool.validation.BundleModulesValidator.validate(BundleModulesValidator.java:101)                   在com.android.tools.build.bundletool.commands.BuildBundleCommand.validateInput(BuildBundleCommand.java:244)                   在com.android.tools.build.bundletool.commands.BuildBundleCommand.execute(BuildBundleCommand.java:162)                   在com.android.build.gradle.internal.tasks.PackageBundleTask $ BundleToolRunnable.run(PackageBundleTask.kt:200)                   在com.android.ide.common.workers.ExecutorServiceAdapter $ submit $ submission $ 1.run(ExecutorServiceAdapter.kt:39)                   ...还有48个

该捆绑包有什么不同?

1 个答案:

答案 0 :(得分:0)

在使用assembleRelease或assembleDebug生成APK时,构建系统会针对不同的动态功能生成不同的apk。一个用于基础,一个用于每个动态功能。因此,没有资源冲突。

如果生成应用程序捆绑包,则生成系统会发生冲突,因为生成的工件是一个单一的工件,即aab文件。