1

I have 3 modules (common, app1, app2) in the common module I've a layout that I want to be black in app1 and white in app2.

Layout.xml

<LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:baselineAligned="false"
        android:orientation="horizontal"
        android:padding="16dp"
        android:background="@color/myColorBackground"
        android:weightSum="4">
...

App1 colors.xml

<ressources>
   <color name="myColorBackground">#fff</color>
</resources>

App2 colors.xml

<ressources>
   <color name="myColorBackground">#000</color>
</resources>

When I try to build the app I got a crash. Is there a solution to use colors like this ?

Biscuit
  • 4,840
  • 4
  • 26
  • 54

2 Answers2

0

when using Modules you need the add the same file in every flavour Or use Common file in main module and override the specific file in required Module.see the image and add files properly

theShaybi
  • 81
  • 6
0

I've found a workaround by adding the <color name="myColorBackground"/> in my common module, now everything is working properly

Biscuit
  • 4,840
  • 4
  • 26
  • 54