Issue
I have 2 android apps. appA
depends on module assets
, appB
depends on moduleB
. moduleB
also depends on assets
.
I'm trying to make R namespacing and added gradle property for that:
android.namespacedRClass=true
.
However after I build the project I see that moduleB
can't access resources from assets
.
This is the file structure:
.
├── appA
│ └─ build
│ └── generated
│ └── not_namespaced_r_class_sources
│ └── debug
│ └── processDebugResources
│ └── r
│ └── my
│ └── package
│ ├── R.java
│ ├── moduleB
│ │ └── feature
│ │ └── R.java
│ └── assets
│ └── R.java
├── AppB
│ │
│ └── ...
├── moduleB
│ └── intermediates
│ └── compile_only_not_namespaced_r_class_jar
│ └── debug
│ └── generateDebugRFile
│ └── R.jar
└── assets
└── src
└── main
└── res
├── color
│ └── ...
├── drawable
│ └── ...
└── values
└── ...
R.jar doesn't contain needed resources. And assets
R is in build for appA
(I guess that's why moduleB
can't access generated R.java
for assets
).
I've seen this approach at SdkSearch app, but it uses single app module. Is it possible to use such approach with 2 apps?
Solution
Assets as android project has manifest with pakage declaration. So I had to import R
class from this package:
<manifest package="my.package.assets" />
import my.package.assets.R as AssetsR
...
val image = context.getDrawable(AssetsR.drawable.image)
Answered By - MightySeal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.