Skip to content

Commit 6ab6f3e

Browse files
trexemDagger Team
authored andcommitted
Throw error while trying to set a dagger flag via annotationProcessor
RELNOTES=Added error while trying to set a dagger flag via annotationProcessor PiperOrigin-RevId: 882008099
1 parent 47dbd13 commit 6ab6f3e

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

dev-guide/compiler-options.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ broken by this change it can usually be fixed by just moving the module to the
6565
correct component. For example, we can fix the case above by installing the
6666
module into the `ActivityComponent` instead of the `SingletonComponent`:
6767

68-
## fastInit mode
68+
## fastInit mode {#fast-init}
6969

7070
You can choose to generate your Dagger [`@Component`]s in a mode that
7171
prioritizes fast initialization. Normally, the number of classes loaded when
@@ -95,9 +95,11 @@ leaks would always have the potential to have grow dependencies on the activity
9595
as the codebase changes (thereby leaking it in the default mode as well).
9696

9797
To enable fastInit mode, pass the following option to javac when building your
98-
Dagger [`@Component`]: `-Adagger.fastInit=enabled`. Note that if you are using
99-
the Hilt Gradle Plugin in your project, fastInit mode will already be enabled by
100-
default.
98+
Dagger [`@Component`]: `-Adagger.fastInit=enabled`.
99+
100+
**Note:** If you are using Hilt, fastInit mode is enabled by default but can be
101+
configured differently. See
102+
[Hilt Fast Init](https://dagger.dev/hilt/flags#fast-init) for more details.
101103

102104
## Turning on code formatting
103105

hilt/flags.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ a migration. To turn off this check, this flag can be used:
7878

7979
`-Adagger.hilt.disableCrossCompilationRootValidation=true`.
8080

81+
## Fast Init {#fast-init}
82+
83+
Hilt ["Fast Init"][fast-init-link] is an optimization that improves
84+
startup performance by avoiding class loading during Hilt initialization. It is
85+
the recommended mode for android applications.
86+
87+
If you are not using the Hilt Gradle plugin, see Dagger's
88+
[compiler options][compiler-options-link] for instructions on how
89+
to enable Fast Init.
90+
91+
If you are using the Hilt Gradle plugin:
92+
93+
* FastInit is enabled by default.
94+
* FastInit can only be disabling via the `dagger.hilt.fastInit` Gradle
95+
property, e.g. via command line: `-Pdagger.hilt.fastInit=false`.
96+
* Hilt will fail if you try to set the flag via Annotation Processing options.
97+
8198
## Runtime flags
8299

83100
Runtime flags to control Hilt behavior for rollout of changes. These flags are
@@ -123,3 +140,6 @@ This flag used to be paired with a compiler option flag
123140
`dagger.hilt.android.useFragmentGetContextFix`, however, as of Dagger 2.40 this
124141
compiler option has now been removed and this behavior is only controlled via
125142
the runtime flag.
143+
144+
[fast-init-link]: https://dagger.dev/compiler-options.html#fastinit-mode
145+
[compiler-options-link]: https://dagger.dev/compiler-options.html#fastinit-mode

0 commit comments

Comments
 (0)