(AS) is the IDE, the software we use to write code, refactor and perform many other daily operations • Gradle is the build system, it’s independent from Android, it can be used for Java-only project and many other builds. • Android Gradle Plugin (AGP) is a custom plugin for Gradle, it provides tasks and configurable settings for your Android build. You could use Android Studio 3.2 with AGP 3.1.4 and Gradle 4.10.2 in your build, that’s fine.
Android Studio feature (introduced in Android Studio 3.2) Incremental Annotation Processing is a Gradle feature (introduce in Gradle 4.7) The new DEX compiler (D8) is a Android Gradle Plugin feature (introduced in AGP 3.1 as experimental, default in AGP 3.2)
are improvements in the latest version you’re not taking advantage of For example, thanks to AGP 3.2.0 and D8 the desugaring of Java 8 languages features is way faster
/gradlew assembleDebug --scan Analyse the result and identify the issues: configuration, execution, parallelism If you want more data, take a look at the Gradle Profiler https://github.com/gradle/gradle-profiler
are configured and the build script are executed. It should last around 1 seconds, better if less. There’s currently a bug in the Kotlin plugin which slows this phase down Configuration is redone every time but since Gradle 4.9 there’s an API for avoidance (not supported by AGP yet)
or in `~/.gradle` Keep it in the root folder and put it under version control org.gradle.parallel=true org.gradle.configureondemand=true org.gradle.daemon=true org.gradle.caching=true org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=1g
a software engineering prospective Better separation of concerns, more clear dependency structure If your app grows, modules scale with it Modules are the key for compilation avoidance Use implementation instead of api
haven’t think about going multimodule from the beginning Asking product manager the time to create an Instant app / App bundles can help you getting the time
generates a R.jar instead of R.java A virtual R class is generated by the IDE to make the developer experience seamless Try new AGP version in a branch of your project!
annotated method class Presenter @Inject constructor(private val repo: SomeRepo) Keep the @Provides for the classes you don’t control Keep modules abstract, avoid passing parameter into the constructor (don’t keep state in there) Use @Binds when you need to bind a implementation to it’s interface type
Subcomponents are generated inside the component that owns them. That meant a lot more code inside the main component in my case Check the LoC of your DaggerApplicationComponent!
app, used in multiple modules, into their own module (notification, base_ui, api, audio…) Create base_di module with a BaseComponent. This is gonna be your main component across the app. In each feature module, have a FeatureComponent who depends on BaseComponent.
(you have to expose the bindings map in the components, merge them manually in the Application and create your own DispatchingAndroidInjectors… You might want to avoid doing that for now
days ago adds support for incremental annotation processing (introduced in Gradle 4.7) Generation of subcomponents ahead of time “Project Bytepoet”: generating bytecode directly instead of Java files (takes around 25% of the time + better for Kotlin!)