Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error using styles in dynamic modules - android app bundle

I'm using the app bundle - dynamic module in my android app. In the project I have a main module and a sub module. In sub module's values -> styles.xml , I have defined custom styles to enable some animations to activities.

<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>

In manifest, I'm using this styles using theme attribute,

<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>

But when I build the project, I'm getting compile error like below,

/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.

What will be reason to this issue?

Any suggestion is appreciated. Thanks.

like image 588
chathura Avatar asked Feb 21 '19 13:02

chathura


1 Answers

Referencing resources from dynamic features from the manifest is not supported today in the Android Gradle Plugin.

One of the reasons is that the manifests of all dynamic features get merged in the manifest of the base module, and the base module should not depend on the dynamic features.

If you define the style in the base, that should fix it.

Source:

From 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.

like image 93
Pierre Avatar answered Sep 21 '22 15:09

Pierre