I am getting Resources$NotFoundException in my dynamic feature module while accessing the layout file. Full error logs below. How can I fix this?
android.content.res.Resources$NotFoundException: Resource ID
#0x7e070001
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:239)
at android.content.res.MiuiResourcesImpl.getValue(MiuiResourcesImpl.java:96)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2317)
at android.content.res.Resources.getLayout(Resources.java:1191)
at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at android.view.View.inflate(View.java:26090)
at com.x.y.player.ContentPlayer.<init>(ContentPlayer.kt:144)
CODE FILE
init {
val view = FrameLayout.inflate(context, R.layout.content_player_layout, this)
videoTextureView = view.findViewById(R.id.videoTextureView)
videoSurfaceView = view.findViewById(R.id.videoSurfaceView)
}
Error on line
val view = FrameLayout.inflate(context, R.layout.content_player_layout, this)
Make sure you are importing the correct package resources. If your inflated layout is in main module, then import main module package resource(R), if it is in dynamic feature module, then import module package resource(R) in your inflated layout class.
Suppose your app main package is "app.main.package" and dynamic feature module package is "app.dynamic.package". Import them accordingly to use the correct resource.
if layout in main=> import app.main.package.R;
if layout in dynamic feature module=> import app.dynamic.package.R;