androidandroid-layout

Android: Include layout file from another module's resources


I working on project PROJ which consist of 2 modules com.example.MOD1 and com.example.MOD2, in MOD2's resource man_layout.xml i want to include sub_layout.xml from MOD1. I do:

MOD2/res/layout/man_layout.xml:

<include
    layout="@com.example.MOD1:layout/sub_layout"/>

But I got error:

No resource found that matches the given name (at 'layout' with value '@com.example.MOD1:layout/sub_layout').

How to include resources from another module within same project? I use android studio and need to reuse same resources in group of projects. Thanks!


Solution

  • To use resources from com.example.MOD1 in com.example.MOD2 com.example.MOD1 must be a library project.