如何解决在模块中将Exoplayer导入为CompileOnly时,Android资源链接失败
在构建将exoplayer导入为仅编译的模块时,会出现错误:
Execution failed for task ‘:xxxxx:verifyReleaseResources'.
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
……..resource id/exo_play not found.
我们在导入到应用程序的模块中实现ExoPlayer。该模块使用“ compileOnly”导入ExoPlayer,如下所示:
compileOnly 'com.google.android.exoplayer:exoplayer-core:xx.xxx.xx’
compileOnly 'com.google.android.exoplayer:exoplayer-ui:xx.xxx.xx'
compileOnly 'com.google.android.exoplayer:exoplayer-hls:xx.xxx.xx'
然后,应用程序为我们导入exoPlayer作为“实现”,如下所示:
implementation "com.google.android.exoplayer:exoplayer-core:xx.xxx.xx”
implementation "com.google.android.exoplayer:exoplayer-hls:xx.xxx.xx"
implementation "com.google.android.exoplayer:exoplayer-ui:xx.xxx.xx"
该模块使用自定义控件布局来覆盖“ exo_play”,如下所示:
<ImageButton
android:id="@id/exo_play"
android:layout_width=“xxxx”
android:layout_height=“xxxx”
android:scaleType="fitXY"
android:src="@drawable/play_icon" />
请注意,我们使用@ id / exo_play代替@ + id / exo_play,因为这是在ExoPlayer中定义的,并且所有自定义控件布局的示例都以这种方式显示。
我们认为,由于我们在模块中覆盖了@ id / exo_play,因此“ verifyReleaseResources”任务正在检查是否在值文件中定义了该值。由于exoPlayer是作为“ compileOnly”导入的,因此此值尚未定义,而是在构建应用程序时定义。因此,发生错误是因为它无法验证是否已找到资源。尽管存在此错误,该模块实际上还是已构建,并且我们能够导入和使用它。只是将构建标记为失败。
我们如何告诉verifyReleaseResources任务此值是在其他位置定义的,并且可以确定在构建模块时未定义该值?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。