It's quite an old question and I am sure the author has found a solution, but I think the question lacks this answer which many people would like to know.
So, actually, as suggested in other answers, this often might be caused by an issue with your architecture.
But sometimes it may be reasonable. For instance, if you need to access your application id inside a library or in many other cases.
So, if you need to access a resource from the app module in a library module,
it can easily be done with help of dependency injection.
For instance, with Dagger it can be done like this:
1.Create a module that will provide a shared resource.
Let's call it the Integration module.
@Module()
class IntegrationModule {
@Provides
@Named("foo")
fun provideFoo() = "Hey bro"
}
2.Include it in your App component
@Component(modules = [
AndroidSupportInjectionModule::class,
AppModule::class,
IntegrationModule::class,
YourLibraryModule::class
])
@Singleton
interface AppComponent : AndroidInjector<App> {
@Component.Builder
interface Builder {
@BindsInstance
fun app(app: Application): Builder
@BindsInstance
fun context(context: Context): Builder
fun build(): AppComponent
}
}
3.Inject it somewhere in your library
@Inject @Named("foo") lateinit var foo: String
That's it.
Base Dagger implementation code is omitted for simplicity.