I want to start modularizing my project but haven't worked out the use-cases for my instant app yet. Can I start refactoring my code using com.android.feature plugin for my installable app today and build my instant app later when I'm ready with product features that I want to ship as an instant app.
2 Answers
Feature plugin allows you to slice your app by features and build it as a library or apk. When consumed by com.android.application
module, the output is aar and when consumed by an instant app module (com.android.instantapp
) , the output is an apk.
You can start slicing your installable app today using feature plugin. All the code that needs to be used only by an installable app can be refactored into a library project. When you are ready to ship your instant app, add an instant app module and include the features that you want.
apply plugin: 'com.android.instantapp'
dependencies {
implementation project(":myFeature")
}
Instant App Documentation: Project structure for Instant Apps
Yes, You can. In fact it is good to start refactoring your code from now if your are planning to make an instant version of your app in future. Till then you can use feature module as a library .aar in your application module. And when you decide to make an instant app just add that feature module to instant app. That's it. It's Always good to do it now than later on.

- 1,041
- 10
- 23