Issue
My project as multiple modules. Inherently, there will be resources that will be used across multiple modules. Let's call this resource logo_image.png
Currently, within the res folder of each module, there exists a copy of logo_image.png. This can be a problem as it can eat up a lot of space.
What I would like to do is to create a Common module, which stores all resources used across the project, and have all references point to a resource in that Common module. Is something like this possible? Here is my attempt at it (that fails)
activity_main.xml
<ImageView
android:id="@+id/imageView"
android:layout_width="300dp"
android:layout_height="150dp"
android:src="@common/drawable/logo_image" /> <-- "Unknown reference
Solution
You can create a module in your project called assets or any other name you want. Then in each module that requires access to common resources, include that module as a dependency, in the module build.gradle
implementation project(':assets')
You would then access the assets like you would if they were defined locally in each module.
<ImageView
android:id="@+id/imageView"
android:layout_width="300dp"
android:layout_height="150dp"
android:src="@drawable/logo_image" />
Answered By - Francesc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.