9

I am trying to implement Dynamic delivery type App. First I create new project after that create Module for dynamic steps for this

Select File > New > New Module from the menu bar and Create New Module dialog, select Dynamic Feature Module and click Next.
structure of folder

I crate class and want to access resource folder for use of layout , drawable folder.

Also implemented in main module gradle

implementation 'com.google.android.play:core:1.2.0' and dynamicFeatures = [":dynamic_feature"]

but getting error for dynamic module Error display

error: cannot find symbol variable activity_main
error: cannot find symbol variable iv_forward
error: cannot find symbol variable seekBar

https://developer.android.com/studio/projects/dynamic-delivery https://proandroiddev.com/dynamic-feature-module-android-ondemand-module-android-app-bundle-ea0d872b32d

Er.nishka
  • 179
  • 1
  • 11

3 Answers3

5

For those who are faced with the same problem: You can only get resources from base module. Use:

com.example.base_module.R.drawable.item

instead off default R.drawable.item

ivanovd422
  • 357
  • 5
  • 18
2

If you are inside dynamic feature module and trying to access the drawable of another module. You should add the the package name of that module (in which drawable is located) as prefix like below

                btnOk.setImageResource(com.example.mysampleproject.R.drawable.Ok)
REMIL K R
  • 21
  • 3
0

This issue looks like a refactoring related import issue to me.

When moving code to a different module make sure to

  1. move related layout resource files
  2. update imports to match the new package name

While 1. is not strictly necessary it is good practice to have non-shared layout files in the same module as the piece of code that displays them.

Ben Weiss
  • 17,182
  • 6
  • 67
  • 87