Notes
-
Do not create a feature under app module
-
Use app module as a bridge between feature modules
-
"com.android.application" mandatory for build android app
-
"com.android.library" for multi modules
-
at least the feature module contain a single activity even though we have a lot of fragments inside.
-
For the applink, we have to standarized the scheme & host. scheme -> bps-app:// :features:home -> bps-app://home :features:splash-screen -> bps-app://splash-screen
-
If we have a few fragments in the feature module, how to navigate into a specific fragment? :features:news NewsActivity -> Tab 1 (Directory), Tab 2 (Favorites)
Path: bps-app://news/directories bps-app://news/favorites
Query: bps-app://news?tab=directories bps-app://news?tab=favorites
Step to module deletion
- Unload module in settings.gradle
- Delete the dependencies in app/build.gradle (if any)
- Sync Now
- Simply right-click the module -> Delete
Steps to create module
-
Create directory -> features
-
Create module -> Android library -> module name: :features:nama-module
-
Make sure the feature module already registered in settings.gradle
-
Add the feature module as a part of app module by: implementation(project(":features:nama-module"))
-
For a special case (such as: the activity launcher), we have to remove the manifest from their own feature module's manifest for that activity, thus, we are able to define the activity inside the app module's manifest.
feature module's manifest:
app module's manifest:
-
Create the applink
-
To navigate the feature module from another module, do like this: val applink = "sample-schema://host" val intent = Intent(Intent.ACTION_VIEW, Uri.parse(applink)) startActivity(intent)
Step to manage the similar dependencies
-
Create the toml file for dependencies management
-
Enable the toml file in settings.gradle.kts versionCatalogs { create("libs") { from(files("libs.dependencies.toml")) } }
-
How to define the dependencies: [versions] variable-name-ver = "1.2.3"
[libraries] variable-name = { module = "sample.test:test", version.ref = "variable-name-ver" }
-
How to call it ? implementation(libs.variable.name)
Architecture Components
- We have to differentiate between mutable and immutable a. Mutable -> read-write (for data changes inside ViewModel) b. Immutable -> read-only (for consuming outside ViewModel, e.g. Activity)