<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Federico Torres on Medium]]></title>
        <description><![CDATA[Stories by Federico Torres on Medium]]></description>
        <link>https://medium.com/@federicotorres?source=rss-fda3ab4e57cf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*S9M4kDecA9wVQGo1.</url>
            <title>Stories by Federico Torres on Medium</title>
            <link>https://medium.com/@federicotorres?source=rss-fda3ab4e57cf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 02:23:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@federicotorres/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Mastering Kotlin Generics: Write Safer, Smarter Code]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://levelup.gitconnected.com/mastering-kotlin-generics-write-safer-smarter-code-7bbf3c992598?source=rss-fda3ab4e57cf------2"><img src="https://cdn-images-1.medium.com/max/1024/1*hC80--RA6VNkBuog9ZVBAQ.png" width="1024"></a></p><p class="medium-feed-snippet">A practical guide to variance, reified types, and type-safe design.</p><p class="medium-feed-link"><a href="https://levelup.gitconnected.com/mastering-kotlin-generics-write-safer-smarter-code-7bbf3c992598?source=rss-fda3ab4e57cf------2">Continue reading on Level Up Coding »</a></p></div>]]></description>
            <link>https://levelup.gitconnected.com/mastering-kotlin-generics-write-safer-smarter-code-7bbf3c992598?source=rss-fda3ab4e57cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bbf3c992598</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin-generics]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Federico Torres]]></dc:creator>
            <pubDate>Tue, 15 Apr 2025 16:00:23 GMT</pubDate>
            <atom:updated>2025-04-15T16:00:23.384Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Bridging the Gap Between Kotlin Multiplatform and Swift]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.nextlevelswift.com/bridging-the-gap-between-kotlin-multiplatform-and-swift-a69c4196459f?source=rss-fda3ab4e57cf------2"><img src="https://cdn-images-1.medium.com/max/1474/0*DjAUdThrkpywtezl" width="1474"></a></p><p class="medium-feed-snippet">Working with Kotlin Multiplatform and Swift? Explore SKIE and learn how this tool simplifies the process and empowers Swift developers.</p><p class="medium-feed-link"><a href="https://medium.nextlevelswift.com/bridging-the-gap-between-kotlin-multiplatform-and-swift-a69c4196459f?source=rss-fda3ab4e57cf------2">Continue reading on Next Level Swift »</a></p></div>]]></description>
            <link>https://medium.nextlevelswift.com/bridging-the-gap-between-kotlin-multiplatform-and-swift-a69c4196459f?source=rss-fda3ab4e57cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/a69c4196459f</guid>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Federico Torres]]></dc:creator>
            <pubDate>Mon, 18 Mar 2024 23:49:44 GMT</pubDate>
            <atom:updated>2024-03-26T17:32:16.315Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Swift: “some View”, Opaque Types and Existential types — fedetorresdev.com]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.nextlevelswift.com/swift-some-view-opaque-types-and-existential-types-fedetorresdev-com-443ee7c59f4e?source=rss-fda3ab4e57cf------2"><img src="https://cdn-images-1.medium.com/max/1800/0*H_Alh_qJce-icdHi" width="1800"></a></p><p class="medium-feed-snippet">Have you ever wondered what is the meaning of some View in SwiftUI views? do you understand what Opaque Types and Existential Types are&#x2026;</p><p class="medium-feed-link"><a href="https://medium.nextlevelswift.com/swift-some-view-opaque-types-and-existential-types-fedetorresdev-com-443ee7c59f4e?source=rss-fda3ab4e57cf------2">Continue reading on Next Level Swift »</a></p></div>]]></description>
            <link>https://medium.nextlevelswift.com/swift-some-view-opaque-types-and-existential-types-fedetorresdev-com-443ee7c59f4e?source=rss-fda3ab4e57cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/443ee7c59f4e</guid>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Federico Torres]]></dc:creator>
            <pubDate>Fri, 15 Dec 2023 15:20:19 GMT</pubDate>
            <atom:updated>2023-12-23T08:52:56.347Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Choosing the Right Mobile App Development Framework: A Comprehensive Guide]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://federicotorres.medium.com/choosing-the-right-mobile-app-development-framework-a-comprehensive-guide-9af4c74acaf9?source=rss-fda3ab4e57cf------2"><img src="https://cdn-images-1.medium.com/max/2600/0*rjWh1P_IWbS0pJyc" width="6720"></a></p><p class="medium-feed-snippet">Deciding which mobile app development framework to use when starting a new mobile application is never an easy task. In this article, I&#x2026;</p><p class="medium-feed-link"><a href="https://federicotorres.medium.com/choosing-the-right-mobile-app-development-framework-a-comprehensive-guide-9af4c74acaf9?source=rss-fda3ab4e57cf------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://federicotorres.medium.com/choosing-the-right-mobile-app-development-framework-a-comprehensive-guide-9af4c74acaf9?source=rss-fda3ab4e57cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/9af4c74acaf9</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[compose-multiplatform]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Federico Torres]]></dc:creator>
            <pubDate>Wed, 01 Nov 2023 04:26:21 GMT</pubDate>
            <atom:updated>2023-11-15T12:02:40.686Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Mastering Lightning-Fast Mobile Searches in KMP Apps: A guide for SQLite and FTS]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/swlh/mastering-lightning-fast-mobile-searches-in-kmp-apps-a-guide-for-sqlite-and-fts-7439732ba9d5?source=rss-fda3ab4e57cf------2"><img src="https://cdn-images-1.medium.com/max/2600/0*OvCTp8yPNO0gBLvO" width="3138"></a></p><p class="medium-feed-snippet">Say goodbye to slow search results and hello to a smoother user experience!</p><p class="medium-feed-link"><a href="https://medium.com/swlh/mastering-lightning-fast-mobile-searches-in-kmp-apps-a-guide-for-sqlite-and-fts-7439732ba9d5?source=rss-fda3ab4e57cf------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/mastering-lightning-fast-mobile-searches-in-kmp-apps-a-guide-for-sqlite-and-fts-7439732ba9d5?source=rss-fda3ab4e57cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/7439732ba9d5</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[full-text-search]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <category><![CDATA[sqldelight]]></category>
            <dc:creator><![CDATA[Federico Torres]]></dc:creator>
            <pubDate>Wed, 27 Sep 2023 13:29:27 GMT</pubDate>
            <atom:updated>2023-09-27T13:29:27.182Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Kotlin Multiplatform Mobile and how to share ViewModel: An architecture proposal]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://proandroiddev.com/kotlin-multiplatform-mobile-and-how-share-viewmodel-an-architecture-proposal-b6f86b61abf9?source=rss-fda3ab4e57cf------2"><img src="https://cdn-images-1.medium.com/max/1200/1*SDxcDmo6qQioCQwTnb5QPg.png" width="1200"></a></p><p class="medium-feed-snippet">In this article I will present a framework for building KMM apps, the objective is share business and presentation logic</p><p class="medium-feed-link"><a href="https://proandroiddev.com/kotlin-multiplatform-mobile-and-how-share-viewmodel-an-architecture-proposal-b6f86b61abf9?source=rss-fda3ab4e57cf------2">Continue reading on ProAndroidDev »</a></p></div>]]></description>
            <link>https://proandroiddev.com/kotlin-multiplatform-mobile-and-how-share-viewmodel-an-architecture-proposal-b6f86b61abf9?source=rss-fda3ab4e57cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6f86b61abf9</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[viewmodel]]></category>
            <category><![CDATA[kotlin-multiplatform]]></category>
            <dc:creator><![CDATA[Federico Torres]]></dc:creator>
            <pubDate>Fri, 28 Jan 2022 02:16:24 GMT</pubDate>
            <atom:updated>2022-01-30T00:37:27.578Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Migrating From LiveData to StateFlow]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/swlh/migrating-from-livedata-to-stateflow-4f28d6889a04?source=rss-fda3ab4e57cf------2"><img src="https://cdn-images-1.medium.com/max/1280/1*VTSdrv_R4f3xy9IK2DRoiA.jpeg" width="1280"></a></p><p class="medium-feed-snippet">I&#x2019;ve worked a lot with LiveData and I think it is a great solution to save the UI state and observe it from the view layer without&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/swlh/migrating-from-livedata-to-stateflow-4f28d6889a04?source=rss-fda3ab4e57cf------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/migrating-from-livedata-to-stateflow-4f28d6889a04?source=rss-fda3ab4e57cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f28d6889a04</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin-coroutines]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Federico Torres]]></dc:creator>
            <pubDate>Wed, 09 Dec 2020 12:05:16 GMT</pubDate>
            <atom:updated>2020-12-11T17:33:53.351Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[RxJava: Take care of code running on main thread]]></title>
            <link>https://federicotorres.medium.com/rxjava-take-care-of-code-running-on-main-thread-a13652205b90?source=rss-fda3ab4e57cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/a13652205b90</guid>
            <category><![CDATA[reactvie]]></category>
            <category><![CDATA[anr]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[rxjava]]></category>
            <dc:creator><![CDATA[Federico Torres]]></dc:creator>
            <pubDate>Thu, 14 Nov 2019 00:32:19 GMT</pubDate>
            <atom:updated>2019-11-14T00:34:37.406Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I have faced one problem on an android project related to RxJava, but first I want to explain two important things:</p><p><strong>ANR</strong></p><p>Acronym for “Application not responding”, if you are an android developer and you don’t know this concept, you should.</p><p>ANR is one of the <strong>Android Vitals, </strong>these are metrics related to the perfomance of your application, tracked by Google. This Android Vitals really affects the ranking of your app and you should take care of it if you want to deliver an app with good quality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*M6tTc4ZAQjOVj26RpC2ZvQ.png" /></figure><p>This message will be shown to the user every time your UI thread is blocked for too long (approximately 5 seconds).</p><p><strong>NetworkOnMainThreadException</strong></p><p>This exception will be thrown every time you make a network operation on the main or UI thread.</p><h3>How can we easily fall into this errors with RxJava</h3><p>So imagine this two classes:</p><pre>class UserRepository (<br>        val service: UserService<br>) {<br>    fun getUser(): Single&lt;User&gt; {<br>        return service.getUser()<br>        .subscribeOn(Schedulers.io())<br>        .observeOn(AndroidSchedulers.mainThread())<br>    }<br>}</pre><pre>class ProfileViewModel (<br>        val userRepository: UserRepository,<br>        val movieRepository: MovieRepository,<br>        val databaseController: DbController</pre><pre>) {<br>    fun getMovies(): {<br>        service.getUser()<br>        .flatMap { user -&gt; movieRepository.getMoviesFor(user) }<br>        .subscribe({//do stuff})</pre><pre>    }</pre><pre>   fun saveUserToDb() : {<br>       service.getUser()<br>        .doOnNext { user -&gt; databaseController.saveUser(user) }<br>        .subscribe({//do stuff})<br>   }</pre><pre><br>}</pre><p>Assuming that <em>movieRepository.getMoviesFor(user) </em>makes an HTTP request, what will happen when you call the method<em> </em>getMovies<em>() </em>of the <em>ProfileVIewModel?</em></p><p>It will throw a <em>NetworkOnMainThreadException, </em>because inside your repository you set the observer scheduler on main thread.</p><p>In <em>saveUserToDb() </em>method you could get an ANR, because you are making I/O operations on the main thread, and remember: I/O operations, or long running operations can produce an ANR.</p><h4>Conclusion</h4><p>Maybe you are thinking this is an obvious mistake, but on large projects when you usually have to make a change on the ViewModel, surely you will don’t even look the code at the repository layer</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a13652205b90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best practice for implementing dagger in multi module projects]]></title>
            <link>https://federicotorres.medium.com/best-practice-for-implementing-dagger-in-multi-module-projects-1e6b3880140d?source=rss-fda3ab4e57cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e6b3880140d</guid>
            <category><![CDATA[dagger]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[multi-module-project]]></category>
            <category><![CDATA[build-time]]></category>
            <dc:creator><![CDATA[Federico Torres]]></dc:creator>
            <pubDate>Tue, 22 Oct 2019 23:58:42 GMT</pubDate>
            <atom:updated>2020-06-26T00:43:41.607Z</atom:updated>
            <content:encoded><![CDATA[<h3>Best practices for implementing dagger in multi module projects</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BB7QM99oLxPkGT9qo3hYuQ.jpeg" /></figure><p>When you have a big application with more than ten or twenty modules, dagger will give you some headaches if it is not implemented right.</p><h3><strong>The problem</strong></h3><p>Imagine an app with a lot of modules, in this app to inject some object to module A you need to add a dependency to another module B, but what happens if module A already depends on B? You have a circular dependency, and also you should know which module provides that object, believe me in large projects it is not good.</p><p>But worst, this nightmare of dependencies between modules provokes that you waste the best advantages of a multi-module project, parallelize building is worthless, and build time is increased.</p><h3>My solution</h3><p>I came across with some good solutions to multi-module projects but none was facing my issue</p><blockquote>Every feature module should be able to get any injectable object without needing to depend on a particular module</blockquote><p>So for this example I created four modules: app, core, login and utilities</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*mTJvHDP9_EO1eHkSp87zfw.jpeg" /></figure><p>Maybe after seeing this picture you are a bit confused, but don’t panic in the next lines I will implement all this modules and dependencies.</p><p>First we will create the project and add all the modules mentioned above.</p><p>After that we must add dependencies to the build.gradle files for each module</p><pre>App Module</pre><pre><em>//Dagger<br></em>api <strong>&quot;com.google.dagger:dagger:</strong>$rootProject.dagger<strong>&quot;<br></strong>kapt <strong>&quot;com.google.dagger:dagger-compiler:</strong>$rootProject.dagger<strong>&quot;<br></strong>api <strong>&quot;com.google.dagger:dagger-android:</strong>$rootProject.dagger<strong>&quot;<br></strong>kapt <strong>&quot;com.google.dagger:dagger-android-processor:</strong>$rootProject.dagger<strong>&quot;</strong></pre><pre>//Modules<br>implementation project(<strong>path</strong>: <strong>&#39;:core&#39;</strong>)<br>implementation project(<strong>path</strong>: <strong>&#39;:login&#39;</strong>)<br>implementation project(<strong>path</strong>: <strong>&#39;:utilities&#39;</strong>)</pre><pre>Core Module</pre><pre><em>//Dagger<br></em>api <strong>&quot;com.google.dagger:dagger:</strong>$rootProject.dagger<strong>&quot;<br></strong>kapt <strong>&quot;com.google.dagger:dagger-compiler:</strong>$rootProject.dagger<strong>&quot;<br></strong>api <strong>&quot;com.google.dagger:dagger-android:</strong>$rootProject.dagger<strong>&quot;<br></strong>kapt <strong>&quot;com.google.dagger:dagger-android-processor:</strong>$rootProject.dagger<strong>&quot;</strong></pre><pre><em>Login module</em></pre><pre><em>//Dagger<br></em>api <strong>&quot;com.google.dagger:dagger:</strong>$rootProject.dagger<strong>&quot;<br></strong>kapt <strong>&quot;com.google.dagger:dagger-compiler:</strong>$rootProject.dagger<strong>&quot;<br></strong>api <strong>&quot;com.google.dagger:dagger-android:</strong>$rootProject.dagger<strong>&quot;<br></strong>kapt <strong>&quot;com.google.dagger:dagger-android-processor:</strong>$rootProject.dagger<strong>&quot;</strong></pre><pre>//Modules<br>implementation project(<strong>path</strong>: <strong>&#39;:core&#39;</strong>)</pre><pre>Utilities Module</pre><pre><em>//Dagger<br></em>api <strong>&quot;com.google.dagger:dagger:</strong>$rootProject.dagger<strong>&quot;<br></strong>kapt <strong>&quot;com.google.dagger:dagger-compiler:</strong>$rootProject.dagger<strong>&quot;<br></strong>api <strong>&quot;com.google.dagger:dagger-android:</strong>$rootProject.dagger<strong>&quot;<br></strong>kapt <strong>&quot;com.google.dagger:dagger-android-processor:</strong>$rootProject.dagger<strong>&quot;</strong></pre><pre>//Modules<br>implementation project(<strong>path</strong>: <strong>&#39;:core&#39;</strong>)</pre><p>So after this initial module configuration, we can start coding our dagger related files.</p><p>The first one will be the <em>AppComponent</em></p><pre>@Component(<br>    modules = [<br>        AndroidInjectionModule::<strong>class</strong>,<br>        ActivityBindingModule::<strong>class<br>    </strong>],<br>    dependencies = [CoreComponent::<strong>class</strong>, UtilsComponent::<strong>class</strong>]<br>)<br>@AppScope<br><strong>interface </strong>AppComponent : AndroidInjector&lt;MainApplication&gt; {<br><br>    @Component.Builder<br>    <strong>interface </strong>Builder {<br>        @BindsInstance<br>        <strong>fun </strong>application(application: Application): AppComponent.Builder<br><br>        <strong>fun </strong>coreComponent(coreComponent: CoreComponent): AppComponent.Builder<br>        <strong>fun </strong>utilsComponent(utilsComponent: UtilsComponent): AppComponent.Builder<br>        <strong>fun </strong>build(): AppComponent<br>    }<br>}</pre><p>Here we are creating the <em>AppComponent </em>adding its module and component dependencies, It ‘s worth mentioning the dependencies between components, this will allow us to provide all the objects provided by Core and Utils components to all the subcomponents of <em>AppComponent, </em>this is the key to what we are looking for.</p><p><em>ActivityBindingModule </em>is where we will provide the injection for our activities</p><pre>@Module<br><strong>abstract class </strong>ActivityBindingModule {<br><br>    @ContributesAndroidInjector<br>    <strong>abstract fun </strong>mainActivity(): MainActivity<br><br>    @ContributesAndroidInjector(modules = [LoginModule::<strong>class</strong>])<br>    <strong>abstract fun </strong>loginActivity(): LoginActivity<br>}</pre><p>The key to understand why this works, is that each time we add a @ContributesAndroidInjector annotation, we are creating a subcomponent of <em>AppComponent s</em>o each of this subcomponents will be able to inject any object of Core, App and Utils components (think it as inheritance)</p><pre>@Module<br><strong>class </strong>LoginModule {<br>    @Provides<br>    <strong>fun </strong>provideFoo() = Foo()<strong><br></strong>}</pre><pre>@Component<br>@Singleton<br><strong>interface </strong>CoreComponent {<br>    <strong>fun </strong>getUserController(): UserController<br><br>}</pre><p>Here is something important to say: An scoped component cannot depend on a component with the same scope, as <em>AppComponent</em> has @AppScope here we define <em>CoreComponent</em> with @Singleton scope, also you could create a new scope called @CoreScope.</p><p>Here <em>UserController</em> will have a single instance for all the application</p><pre>@Component(modules = [UtilsModule::<strong>class</strong>])<br><strong>interface </strong>UtilsComponent {<br><br>    <strong>fun </strong>getResourceProvider() : IResourceProvider<br><br>    @Component.Builder<br>    <strong>interface </strong>Builder {<br>        @BindsInstance<br>        <strong>fun </strong>application(application: Application): UtilsComponent.Builder<br><br>        <strong>fun </strong>build(): UtilsComponent<br>    }<br>}</pre><pre>@Module<br><strong>abstract class </strong>UtilsModule {<br><br>    @Binds<br>    <strong>abstract fun </strong>bindContext(application: Application): Context<br><br>    @Module<br>    <strong>companion object </strong>{<br>        @Provides<br>        @JvmStatic<br>        <strong>fun </strong>bindResourceProvider(context: Context): IResourceProvider {<br>            <strong>return </strong>ResourceProviderImpl(context)<br>        }<br>    }<br><br>}</pre><p>Here we are providing an interface for inflating android related resources, this class needs a context that is why we created a method to pass the application object and later we bind it to context.</p><p>So we need to do one more thing to make this work, we need to create a custom Application class to create the <em>AppComponent</em></p><pre><strong>class </strong>MainApplication : DaggerApplication() {<br><br><br>    <strong>fun </strong>applicationInjector(): AndroidInjector&lt;<strong>out </strong>DaggerApplication&gt; {<br>        <strong>return </strong>DaggerAppComponent<br>            .builder()<br>            .application(<strong>this</strong>)<br>            .coreComponent(provideCoreComponent())<br>            .utilsComponent(getUtilsComponent())<br>            .build()<br><br>    }<br><br><br>    <strong>fun </strong>provideCoreComponent(): CoreComponent {<br>            <strong>return</strong> DaggerCoreComponent<br>                .builder()<br>                .build()<strong><br>    </strong>}<br><br>    <strong>private fun </strong>getUtilsComponent(): UtilsComponent {<br>        <strong>return </strong>DaggerUtilsComponent<br>            .builder()<br>            .application(<strong>this</strong>)<br>            .build()<br>    }<br><br><br>}</pre><p>Now we can add all the modules we want on the project with just one module dependency: Core</p><h4>Why Core Module?</h4><p>Because this module must contain all the interfaces that will be injected in feature modules, <em>IResourceProvider</em> is at core module, but <em>ResourceProviderImpl</em> is on utilities module, so core module does not contain the logic to provide resources, just the interface.</p><pre><strong>class </strong>ResourceProviderImpl(<strong>val context</strong>: Context) : IResourceProvider {<br><br>    <strong>override fun </strong>getString(resourceId: Int): String {<br>        <strong>return context</strong>.getString(resourceId).<em>orEmpty</em>()<br>    }<br><br>    <strong>override fun </strong>getString(id: Int, <strong>vararg </strong>args: Any?): String {<br>        <strong>return context</strong>.getString(id, *args)<br>    }<br><br><br>    <strong>override fun </strong>getDrawable(drawableRes: Int): Drawable {<br>        <strong>return </strong><em>requireNotNull</em>(ContextCompat.getDrawable(<strong>context</strong>, drawableRes))<br>    }<br>}</pre><h4>Injecting dependencies</h4><p>Now we can do something like this:</p><pre><strong>class </strong>LoginActivity : AppCompatActivity() {<br><br>    @Inject<br>    <strong>lateinit var foo</strong>: Foo()<br><br>    @Inject<br>    <strong>lateinit var userController</strong>: UserController<br><br>    @Inject<br>    <strong>lateinit var resourceProvider</strong>: IResourceProvider<br><br>    <strong>override fun </strong>onCreate(savedInstanceState: Bundle?) {<br>        AndroidInjection.inject(<strong>this</strong>)<br>        <strong>super</strong>.onCreate(savedInstanceState)<br>        setContentView(R.layout.<em>activity_login</em>)<br><br><br>        <strong>val </strong>textView = findViewById&lt;TextView&gt;(R.id.<em>textView</em>)<br>        textView.<em>text </em>= <strong>resourceProvider</strong>.getString(R.string.<em>app_name</em>)<br>    }<br>}</pre><p>Note this: login module do not depend on utilities module, but the injection is successful</p><h4>Conclusion</h4><p>I hope this helps you simplify your dagger implementation on large multi module projects, this helps improving build time and keeping a clean app architecture.</p><p><strong>Update</strong>: I made a sample app showing how I implemented this: <a href="https://github.com/fededri/DaggerMultiModulesDemo">https://github.com/fededri/DaggerMultiModulesDemo</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e6b3880140d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>