├── .gitignore ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml └── runConfigurations.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── multimodule │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── multimodule │ │ │ ├── MainActivity.kt │ │ │ ├── app │ │ │ └── CustomApplication.kt │ │ │ └── di │ │ │ ├── ApplicationComponent.kt │ │ │ └── provider │ │ │ └── ApplicationComponentProvider.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── example │ └── multimodule │ └── ExampleUnitTest.kt ├── build.gradle ├── calculator ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── calculator │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── calculator │ │ │ ├── di │ │ │ ├── CalculatorComponent.kt │ │ │ ├── CalculatorModule.kt │ │ │ └── provider │ │ │ │ └── CalculatorComponentProvider.kt │ │ │ ├── ui │ │ │ └── CalculatorActivity.kt │ │ │ └── usecase │ │ │ └── SumUseCase.kt │ └── res │ │ ├── layout │ │ └── acitivity_calculator.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── example │ └── calculator │ └── ExampleUnitTest.kt ├── core ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── core │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── core │ │ │ ├── di │ │ │ ├── CoreModule.kt │ │ │ └── SuscriptionModule.kt │ │ │ ├── modes │ │ │ └── AppSuscription.kt │ │ │ └── resource │ │ │ └── StringsProvider.kt │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── example │ └── core │ └── ExampleUnitTest.kt ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/java,maven,gradle,kotlin,android,intellij,androidstudio 3 | # Edit at https://www.gitignore.io/?templates=java,maven,gradle,kotlin,android,intellij,androidstudio 4 | 5 | ### Android ### 6 | # Built application files 7 | *.apk 8 | *.ap_ 9 | *.aab 10 | 11 | # Files for the ART/Dalvik VM 12 | *.dex 13 | 14 | # Java class files 15 | *.class 16 | 17 | # Generated files 18 | bin/ 19 | gen/ 20 | out/ 21 | release/ 22 | 23 | # Gradle files 24 | .gradle/ 25 | build/ 26 | 27 | # Local configuration file (sdk path, etc) 28 | local.properties 29 | 30 | # Proguard folder generated by Eclipse 31 | proguard/ 32 | 33 | # Log Files 34 | *.log 35 | 36 | # Android Studio Navigation editor temp files 37 | .navigation/ 38 | 39 | # Android Studio captures folder 40 | captures/ 41 | 42 | # IntelliJ 43 | *.iml 44 | .idea/workspace.xml 45 | .idea/tasks.xml 46 | .idea/gradle.xml 47 | .idea/assetWizardSettings.xml 48 | .idea/dictionaries 49 | .idea/libraries 50 | # Android Studio 3 in .gitignore file. 51 | .idea/caches 52 | .idea/modules.xml 53 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 54 | .idea/navEditor.xml 55 | 56 | # Keystore files 57 | # Uncomment the following lines if you do not want to check your keystore files in. 58 | #*.jks 59 | #*.keystore 60 | 61 | # External native build folder generated in Android Studio 2.2 and later 62 | .externalNativeBuild 63 | 64 | # Google Services (e.g. APIs or Firebase) 65 | # google-services.json 66 | 67 | # Freeline 68 | freeline.py 69 | freeline/ 70 | freeline_project_description.json 71 | 72 | # fastlane 73 | fastlane/report.xml 74 | fastlane/Preview.html 75 | fastlane/screenshots 76 | fastlane/test_output 77 | fastlane/readme.md 78 | 79 | # Version control 80 | vcs.xml 81 | 82 | # lint 83 | lint/intermediates/ 84 | lint/generated/ 85 | lint/outputs/ 86 | lint/tmp/ 87 | # lint/reports/ 88 | 89 | ### Android Patch ### 90 | gen-external-apklibs 91 | output.json 92 | 93 | # Replacement of .externalNativeBuild directories introduced 94 | # with Android Studio 3.5. 95 | .cxx/ 96 | 97 | ### Intellij ### 98 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 99 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 100 | 101 | # User-specific stuff 102 | .idea/**/workspace.xml 103 | .idea/**/tasks.xml 104 | .idea/**/usage.statistics.xml 105 | .idea/**/dictionaries 106 | .idea/**/shelf 107 | 108 | # Generated files 109 | .idea/**/contentModel.xml 110 | 111 | # Sensitive or high-churn files 112 | .idea/**/dataSources/ 113 | .idea/**/dataSources.ids 114 | .idea/**/dataSources.local.xml 115 | .idea/**/sqlDataSources.xml 116 | .idea/**/dynamic.xml 117 | .idea/**/uiDesigner.xml 118 | .idea/**/dbnavigator.xml 119 | 120 | # Gradle 121 | .idea/**/gradle.xml 122 | .idea/**/libraries 123 | 124 | # Gradle and Maven with auto-import 125 | # When using Gradle or Maven with auto-import, you should exclude module files, 126 | # since they will be recreated, and may cause churn. Uncomment if using 127 | # auto-import. 128 | # .idea/modules.xml 129 | # .idea/*.iml 130 | # .idea/modules 131 | # *.iml 132 | # *.ipr 133 | 134 | # CMake 135 | cmake-build-*/ 136 | 137 | # Mongo Explorer plugin 138 | .idea/**/mongoSettings.xml 139 | 140 | # File-based project format 141 | *.iws 142 | 143 | # IntelliJ 144 | 145 | # mpeltonen/sbt-idea plugin 146 | .idea_modules/ 147 | 148 | # JIRA plugin 149 | atlassian-ide-plugin.xml 150 | 151 | # Cursive Clojure plugin 152 | .idea/replstate.xml 153 | 154 | # Crashlytics plugin (for Android Studio and IntelliJ) 155 | com_crashlytics_export_strings.xml 156 | crashlytics.properties 157 | crashlytics-build.properties 158 | fabric.properties 159 | 160 | # Editor-based Rest Client 161 | .idea/httpRequests 162 | 163 | # Android studio 3.1+ serialized cache file 164 | .idea/caches/build_file_checksums.ser 165 | 166 | ### Intellij Patch ### 167 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 168 | 169 | # *.iml 170 | # modules.xml 171 | # .idea/misc.xml 172 | # *.ipr 173 | 174 | # Sonarlint plugin 175 | .idea/**/sonarlint/ 176 | 177 | # SonarQube Plugin 178 | .idea/**/sonarIssues.xml 179 | 180 | # Markdown Navigator plugin 181 | .idea/**/markdown-navigator.xml 182 | .idea/**/markdown-navigator/ 183 | 184 | ### Java ### 185 | # Compiled class file 186 | 187 | # Log file 188 | 189 | # BlueJ files 190 | *.ctxt 191 | 192 | # Mobile Tools for Java (J2ME) 193 | .mtj.tmp/ 194 | 195 | # Package Files # 196 | *.jar 197 | *.war 198 | *.nar 199 | *.ear 200 | *.zip 201 | *.tar.gz 202 | *.rar 203 | 204 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 205 | hs_err_pid* 206 | 207 | ### Kotlin ### 208 | # Compiled class file 209 | 210 | # Log file 211 | 212 | # BlueJ files 213 | 214 | # Mobile Tools for Java (J2ME) 215 | 216 | # Package Files # 217 | 218 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 219 | 220 | ### Maven ### 221 | target/ 222 | pom.xml.tag 223 | pom.xml.releaseBackup 224 | pom.xml.versionsBackup 225 | pom.xml.next 226 | release.properties 227 | dependency-reduced-pom.xml 228 | buildNumber.properties 229 | .mvn/timing.properties 230 | .mvn/wrapper/maven-wrapper.jar 231 | .flattened-pom.xml 232 | 233 | ### Gradle ### 234 | .gradle 235 | 236 | # Ignore Gradle GUI config 237 | gradle-app.setting 238 | 239 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 240 | !gradle-wrapper.jar 241 | 242 | # Cache of project 243 | .gradletasknamecache 244 | 245 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 246 | # gradle/wrapper/gradle-wrapper.properties 247 | 248 | ### Gradle Patch ### 249 | **/build/ 250 | 251 | ### AndroidStudio ### 252 | # Covers files to be ignored for android development using Android Studio. 253 | 254 | # Built application files 255 | 256 | # Files for the ART/Dalvik VM 257 | 258 | # Java class files 259 | 260 | # Generated files 261 | 262 | # Gradle files 263 | 264 | # Signing files 265 | .signing/ 266 | 267 | # Local configuration file (sdk path, etc) 268 | 269 | # Proguard folder generated by Eclipse 270 | 271 | # Log Files 272 | 273 | # Android Studio 274 | /*/build/ 275 | /*/local.properties 276 | /*/out 277 | /*/*/build 278 | /*/*/production 279 | *.ipr 280 | *~ 281 | *.swp 282 | 283 | # Android Patch 284 | 285 | # External native build folder generated in Android Studio 2.2 and later 286 | 287 | # NDK 288 | obj/ 289 | 290 | # IntelliJ IDEA 291 | /out/ 292 | 293 | # User-specific configurations 294 | .idea/caches/ 295 | .idea/libraries/ 296 | .idea/shelf/ 297 | .idea/.name 298 | .idea/compiler.xml 299 | .idea/copyright/profiles_settings.xml 300 | .idea/encodings.xml 301 | .idea/misc.xml 302 | .idea/scopes/scope_settings.xml 303 | .idea/vcs.xml 304 | .idea/jsLibraryMappings.xml 305 | .idea/datasources.xml 306 | .idea/dataSources.ids 307 | .idea/sqlDataSources.xml 308 | .idea/dynamic.xml 309 | .idea/uiDesigner.xml 310 | 311 | # OS-specific files 312 | .DS_Store 313 | .DS_Store? 314 | ._* 315 | .Spotlight-V100 316 | .Trashes 317 | ehthumbs.db 318 | Thumbs.db 319 | 320 | # Legacy Eclipse project files 321 | .classpath 322 | .project 323 | .cproject 324 | .settings/ 325 | 326 | # Mobile Tools for Java (J2ME) 327 | 328 | # Package Files # 329 | 330 | # virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) 331 | 332 | ## Plugin-specific files: 333 | 334 | # mpeltonen/sbt-idea plugin 335 | 336 | # JIRA plugin 337 | 338 | # Mongo Explorer plugin 339 | .idea/mongoSettings.xml 340 | 341 | # Crashlytics plugin (for Android Studio and IntelliJ) 342 | 343 | ### AndroidStudio Patch ### 344 | 345 | !/gradle/wrapper/gradle-wrapper.jar 346 | 347 | # End of https://www.gitignore.io/api/java,maven,gradle,kotlin,android,intellij,androidstudio -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | xmlns:android 17 | 18 | ^$ 19 | 20 | 21 | 22 |
23 |
24 | 25 | 26 | 27 | xmlns:.* 28 | 29 | ^$ 30 | 31 | 32 | BY_NAME 33 | 34 |
35 |
36 | 37 | 38 | 39 | .*:id 40 | 41 | http://schemas.android.com/apk/res/android 42 | 43 | 44 | 45 |
46 |
47 | 48 | 49 | 50 | .*:name 51 | 52 | http://schemas.android.com/apk/res/android 53 | 54 | 55 | 56 |
57 |
58 | 59 | 60 | 61 | name 62 | 63 | ^$ 64 | 65 | 66 | 67 |
68 |
69 | 70 | 71 | 72 | style 73 | 74 | ^$ 75 | 76 | 77 | 78 |
79 |
80 | 81 | 82 | 83 | .* 84 | 85 | ^$ 86 | 87 | 88 | BY_NAME 89 | 90 |
91 |
92 | 93 | 94 | 95 | .* 96 | 97 | http://schemas.android.com/apk/res/android 98 | 99 | 100 | ANDROID_ATTRIBUTE_ORDER 101 | 102 |
103 |
104 | 105 | 106 | 107 | .* 108 | 109 | .* 110 | 111 | 112 | BY_NAME 113 | 114 |
115 |
116 |
117 |
118 | 119 | 121 |
122 |
-------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dagger-multi-module 2 | Dagger Multi Module approach 3 | 4 | Do you want to know more about this Repo? Take a look at: 5 | 6 | [Español: Android Multi-Module y Dagger: un caso real, paso a paso](https://medium.com/@juliann_ezeqiel/android-multi-module-y-dagger-un-caso-real-paso-a-paso-47baff76e1ca) 7 | 8 | [English: Android Multi-Module & Dagger: a real use case, step by step](https://proandroiddev.com/android-multi-module-dagger-a-real-use-case-step-by-step-bbc03500f2f9) 9 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | apply plugin: 'kotlin-kapt' 5 | 6 | android { 7 | compileSdkVersion 29 8 | defaultConfig { 9 | applicationId "com.example.multimodule" 10 | minSdkVersion 21 11 | targetSdkVersion 29 12 | versionCode 1 13 | versionName "1.0" 14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | implementation fileTree(dir: 'libs', include: ['*.jar']) 26 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 27 | implementation 'androidx.appcompat:appcompat:1.1.0' 28 | implementation 'androidx.core:core-ktx:1.2.0' 29 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 30 | testImplementation 'junit:junit:4.12' 31 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 32 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 33 | 34 | implementation project(':core') 35 | implementation project(':calculator') 36 | 37 | api 'com.google.dagger:dagger:2.27' 38 | kapt 'com.google.dagger:dagger-compiler:2.27' 39 | } 40 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/multimodule/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.example.multimodule 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.example.multimodule", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/multimodule/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.multimodule 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import android.widget.Button 6 | import android.widget.TextView 7 | import androidx.appcompat.app.AppCompatActivity 8 | import com.example.calculator.ui.CalculatorActivity 9 | import com.example.core.modes.AppSuscription 10 | import com.example.multimodule.di.provider.ApplicationComponentProvider 11 | import javax.inject.Inject 12 | 13 | class MainActivity : AppCompatActivity() { 14 | 15 | @Inject 16 | lateinit var appSuscription: AppSuscription 17 | 18 | lateinit var suscriptionTextView: TextView 19 | 20 | override fun onCreate(savedInstanceState: Bundle?) { 21 | super.onCreate(savedInstanceState) 22 | setContentView(R.layout.activity_main) 23 | 24 | (application as ApplicationComponentProvider) 25 | .getApplicationComponent() 26 | .inject(this) 27 | 28 | bindViews() 29 | bindListeners() 30 | 31 | showSuscription() 32 | } 33 | 34 | private fun showSuscription() { 35 | suscriptionTextView.text = appSuscription.getUserSuscription() 36 | } 37 | 38 | private fun startCalculatorActivity() { 39 | startActivity( 40 | Intent(this, CalculatorActivity::class.java) 41 | ) 42 | } 43 | 44 | private fun bindViews() { 45 | suscriptionTextView = findViewById(R.id.suscription_type_textview) 46 | } 47 | 48 | private fun bindListeners() { 49 | findViewById