动态特性发布构建失败,存在重复资源。

3
我正在创建一个示例来检查 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’失败。 at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77) ... Caused by: org.gradle.internal.UncheckedException: java.util.concurrent.ExecutionException: com.android.tools.build.bundletool.exceptions.ValidationException: Modules 'base' and 'sample_dynamic_feature' contain entry 'res/layout/activity_main.xml' with different content. at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:63) at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40) ... Caused by: java.util.concurrent.ExecutionException: com.android.tools.build.bundletool.exceptions.ValidationException: Modules 'base' and 'sample_dynamic_feature' contain entry 'res/layout/activity_main.xml' with different content. at com.android.ide.common.workers.ExecutorServiceAdapter.close(ExecutorServiceAdapter.kt:56) ... Caused by: com.android.tools.build.bundletool.exceptions.ValidationException: Modules 'base' and 'sample_dynamic_feature' contain entry 'res/layout/activity_main.xml' with different content. at com.android.tools.build.bundletool.exceptions.ValidationException$Builder.build(ValidationException.java:49) ...
这个包有什么区别?
1个回答

1
使用 assembleRelease 或 assembleDebug 生成 APK 时,构建系统会为不同的动态功能生成不同的 APK。其中一个用于基本功能,每个动态功能都有一个。因此,不存在资源冲突。
如果生成应用程序包,则构建系统会发生冲突,因为生成的工件是一个单一的工件,即 aab 文件。

有没有解决方案? - nilkash
在基础模块和动态模块中,只需将布局名称设置为不同即可。两个相同名称的布局将始终发生冲突。 - Dinesh
如果您使用两个具有相同资源名称的库会发生什么? - c0dehunter
@PrimožKralj,如果这些库有相同的资源名称,你能找到解决方案吗? - Alankrita Shah
我没有 :( - c0dehunter

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接