A typical Android project, with current best practices from the Gradle and Android team. Suitable for starting a project from scratch or testing and reviewing certain approaches.
- Gradle: 8.6
- Android Gradle Plugin: 8.1.4
- Kotlin: 1.9.22
- Compile SDK: 34
- Target SDK: 34
- Min SDK: 24
The main scripts for gradle-profiler can be found in the directory [/build-logic/performance/].
- clean-build.scenarios - Cold assembly measurements. https://developer.android.com/build/profile-your-build#profiling_a_clean_build
- configuration.scenarios - Measurements of configuration time.
- incremental-build.scenarios - Profiling an incremental build. https://developer.android.com/build/profile-your-build#profiling_an_incremental_build
- jvm-args.scenarios - Profiling different memory/CPU settings. https://developer.android.com/build/profile-your-build#profiling_different_memorycpu_settings
- plugin-version.scenarios - Profiling different Gradle and Android Gradle plugin versions. https://developer.android.com/build/profile-your-build#profiling_different_gradle_plugin_versions
Update third-party plugins in a timely manner.
- English locale
- Dimensions xxhdpi
Disabled by default for debug
since AGP 3.0, if you have other build types,
disable isCrunchPngs
.
Always check which GC is better for your project: G1GC
(default) or ParallelGC
.
Here ParallelGC
is used.
See recommendations in gradle.properties in the comment to org.gradle.jvmargs
.
It is better to carry out tests for frequently encountered cars, so that there is no swap and friezes when development.
If for some reason you use jetifier, discard the outdated libraries or repackage (use androidx) the libraries.
If you are using plugins that do not support cache, enable
the org.gradle.configuration-cache.problems=warn
flag, and the cache itself must be disabled.
If you have Third-Party or your own logic, check the problems for incrementality.
CI: uses remote cache, can push to remote cache.
Local machine: uses the remote cache, cannot push to the remote cache, so as not to break remote cache.
Always use the same version of Java on CI and on local machines.
- Select the optimal Java version and vendor
- Instruct developers to use a single version of Java
- Or preinstall the environment at the gradle-user-home level
- Or make a custom gradle-wrapper and distribute it through your server
Be sure to check the builds for cache miss. Example, if you use Room, then there is a cache problem miss with the schema file.
Coming Soon!
- Files are not read during configuration
- There is no rigid connection between the 'allprojects' or 'subprojects' plugins
- Uses static Kotlin and conevention plugins instead of Groovy scripts
Coming Soon! You need to analyze the entire assembly.
If you only use a small portion of the library, consider writing your own implementation or looking for a lightweight library.
Disable unused libraries, you can use various plugins.
Coming Soon! Select a plugin.
If you have Nexus or another dependency proxy. Leave one point, you will reduce the number of
requests. Uncomment the required code in setting.gradle
.
May slow down tests. If possible, you can use fakes.
Coming Soon! Make average test results and add scripts for gradle-profiler.
Coming Soon!
Coming Soon! Testing and report.
Coming Soon! Add flexible settings to enable and disable reports.
Use multimodularity to achieve maximum build paralysis and feature isolation.
Coming Soon!
- Add convention plugin for the Kotlin module
- Make sample modules using pure Kotlin
To most often use pure Kotlin modules, the aar to jar transformation is used.
Coming Soon!
- Add a plugin with aar to jar transformation
- Make a sample module using transformation
- Add links to useful resources
- Follow best practices from the Android team to reduce the weight of your apk
- Do periodic cleaning
- Use static code analyzers to promptly remove unused code
buildfeatures
are disabled in Gradle 8.0 by default, if you have a lower version of Gradle,
disable it for yourself.
Coming Soon! Add sample how to use global BuildConfig.
If your project has minSdk version less than 24, use minSdk 24+ on development machines, and minSdk < 24 on CI.
Coming Soon! Add sample custom parameter minSdk.
Avoid combinatorial explosion of tasks on your project. If you need to separate your product into different flavors, use the gradle property and custom build logic.
Coming Soon! Add sample implementation of taste via gradle property.
This construction will create not one project (:project:core:uikit
), but three
projects: project
, core
, uikit
. This means that these projects will participate in the
configuration.
If the configuration is slow: write a plugin that will connect modules or use patches.
Coming Soon!
- Write and test a plugin
- Test and add results to see how much the configuration differs
For submodules, only the debug or release option is used. Use matchingFallbacks.
Coming Soon! Test and add results to see how much the configuration differs.
Coming Soon! Add links for performance comparison.
In general, this functionality is constantly being improved by the Gradle team and it is convenient.
Coming Soon!
Coming Soon!
Coming Soon!
Coming Soon! Bazel implementation branch.
Coming Soon!
- Tab navigation with 5 fragments
- Each tab has a graph of 10 fragments
- About 50 features
- About 100 modules
- app: main project configuration, application build
- build-logic: project build logic
- docs: accompanying documentation for the project
- gradle: everything related to gradle is the wrapper and libs directory
- product: the project code base, here is all the functionality of the application
- sample-app: project configuration of dependencies that a developer needs to develop a feature
- Language: Kotlin
- Architecture: MVVM (Google), clean, multi-module
- UI: Compose, Material 3
- Navigation: Jetpack Compose Navigation
- DI: Hilt
- Testing: Coming Soon!
debug
- Logging, debug mode, proguard off.
release
- No logging, no debug mode, proguard enabled.
Copyright 2023 Roman Likhachev
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.