在动态模块中使用样式时出错 - android app bundle

error using styles in dynamic modules - android app bundle

我在 android 应用程序中使用应用程序包 - 动态模块。在项目中,我有一个主模块和一个子模块。在子模块的 values -> styles.xml 中,我定义了自定义样式来为活动启用一些动画。

<style name="SampleActivityTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="buttonStyle">@style/CustomButtonStyle</item>
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowActivityTransitions">true</item>
    <item name="android:windowEnterTransition">@transition/activity_transition_note</item>
    <item name="android:windowExitTransition">@transition/activity_transition_note</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>

在清单中,我使用主题属性使用此样式,

<activity
        android:name=".activity.SampleActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|locale"
        android:label=""
        android:screenOrientation="portrait"
        android:theme="@style/SampleActivityTheme">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
        </intent-filter>
</activity>

但是当我构建项目时,出现如下编译错误,

/Users/chathura/Branches/AppBundle/sample_module/build/intermediates/merged_manifests/debug/AndroidManifest.xml:778: error: resource style/SampleActivityTheme (aka lk.sample.mysampleapp:style/SampleActivityTheme) not found.

这个问题的原因是什么?

如有任何建议,我们将不胜感激。 谢谢

目前 Android Gradle 插件不支持从清单中的动态功能引用资源。

原因之一是所有动态特性的清单都合并到基础模块的清单中,基础模块不应该依赖于动态特性。

如果您在基础中定义样式,应该可以解决它。

来源:

来自https://developer.android.com/studio/projects/dynamic-delivery

The manifest for your app’s base module is similar to that of any other app module. Keep in mind, when Google Play generates your app’s base APK, it merges manifests for all modules into that of the base APK.