如何在动态特性模块中包含 AAR?

How to include AAR in Dynamic Feature Module?

我想将一个大的 AAR 库(“crypteriumsdk”)放入动态功能模块中,可以按需安装。但是当我这样做时,它找不到它的资源(主题):

resource style/CrypteriumTheme (aka com.crypter.cryptocyrrency:style/CrypteriumTheme) not found.

我还在主清单(应用程序模块)中将 tools:replace="android:theme" 添加到 application

这里有什么问题?

settings.gradle:

include ':crypteriumsdk'
include ':wallet'
include ':app'

wallet.gradle:

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation project(":app")
    implementation project(':crypteriumsdk') // added the library here
}

Manifest 合并得太早,实际的主题实现无法在用户设备上使用。

您可以将其添加到基础模块的 styles.xml:

    <style name="CrypteriumTheme" />

这允许在安装时找到样式资源 ID,并在模块可用和启动后覆盖它。

请参阅 this sample 了解工作实施。