Android Dynamic Feature Modules: My Experience

  • I was able to reuse the code of my main module into the dynamic module (Classes, Resources, and almost everything) which is not possible in a normal module. As I was following MVP structure, I reused the same base classes. For resources also, there was no need to add them separately but to reuse from the main module.
  • I was able to implement Dependency injection and maintain it in the dynamic module separately.
  • As I planned to create a separate CameraActivity in my dynamic module, which was supposed to be launched from the main module, I didn’t get the reference of my dynamic modules classes in the main module classes. This was understandable as my main module was not dependant on the dynamic module but the other way around. To fix this issue and start my activity present in the Camera module I used the classpath to start the activity.
val intent = Intent().setClassName(packageName,
"<complete class path of camera activity>")
startActivity(intent)
java -jar <jar file path> build-apks --bundle=<aab file path> --output=<output file path>
java -jar ~/Desktop/release/bundletool-all-0.7.2.jar build-apks --bundle=~/Desktop/release/app.aab --output=~/Desktop/release/out.apks
unzip out.apks -d apks
java -jar ~/Desktop/release/bundletool-all-0.7.2.jar build-apks --bundle=~/Desktop/release/app.aab --output=~/Desktop/release/out.apks --ks <keytore file path> --ks-key-alias <alias>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store